MATLAB中如何将多个方程组合并成一个方程?

img

如何将上图的方程组合并成一个方程,并将方程提取参数,化简成sin(theta5)和cos(theta5)变量的形式。

你好,你的方程里面存在sin(theta5)*cos(theta5)的项,这样前面的参数A和B事实上是混合了cos(theta5)和sin(theta5),请检查:
思想供参考

syms l4 theta5 lp1 n1 l5 px nx ny py theta4 l3
eq1 = -2*l3*l5*cos(theta5) - 2*(l5*lp1*nx-l5*px)*cos(theta5+theta5)-...
    2*(l5*lp1*ny-l5*py)*sin(theta4+theta5);
eq2 = l4^2+l5^2-l3^2+(nx^2+ny^2)*lp1^2 - 2*lp1*(nx*px+ny*py) + px^2+py^2+...
2*(l4*lp1*nx-l4*px)*cos(theta4) + 2*(l4*lp1*ny-l4*py)*sin(theta4);
eq = eq1-eq2;
eq = expand(eq);
C = -subs(subs(eq, sin(theta5),0),cos(theta5),0)
eq = eq+C;

A = subs(eq, cos(theta5),0)
B = subs(eq, sin(theta5),0)

结果:

C =
 
- l3^2 + l4^2 + 2*cos(theta4)*l4*lp1*nx + 2*sin(theta4)*l4*lp1*ny - 2*cos(theta4)*l4*px - 2*sin(theta4)*l4*py + l5^2 - 2*l5*lp1*nx + 2*l5*px + lp1^2*nx^2 + lp1^2*ny^2 - 2*lp1*nx*px - 2*lp1*ny*py + px^2 + py^2
 
 
A =
 
2*l5*py*cos(theta4)*sin(theta5) - 2*l5*lp1*ny*cos(theta4)*sin(theta5)
 
 
B =
 
4*l5*px*cos(theta5)^2 - 2*l3*l5*cos(theta5) - 4*l5*lp1*nx*cos(theta5)^2 + 2*l5*py*cos(theta5)*sin(theta4) - 2*l5*lp1*ny*cos(theta5)*sin(theta4)


可以好好讨论,有帮助望采纳