Matlab符号工具箱(一)化简方程

翻老代码发现之前写了一个简单的符号工具箱化简方程,好久不用遗忘了,留个代码备份

syms fx fy
fy2 = floor(fy/2)*2;
fx2 = floor(fx/2)*2;

x_f2 = fx - fy2;
y_f2 = fy - fx2;

xr = (fx - fy) / 2;
yr = (fx + fy) / 2;
xr_f = xr - floor(xr);
yr_f = yr - floor(yr);

x_fg = yr_f + xr_f;
y_fg = yr_f - xr_f;

delta_x = x_f2 - x_fg;
delta_y = y_f2 - y_fg;

xr_m = (delta_x + delta_y) / 2;
yr_m = (delta_x - delta_y) / 2;

simple_x = simplify(xr_m)
simple_y = simplify(yr_m)

发表评论