Why is it so hard for MATLAB to solve the following symbolic equation

8 次查看(过去 30 天)
syms rp alpha beta theta psi z
A=cos(alpha)-cos(beta);
B=sin(alpha)-sin(beta);
C=(cos(beta)-1)/tan(beta)-(cos(alpha)-1)/tan(alpha);
R=A*(cos(theta)-cos(psi))+B*cos(theta)*sin(psi);
S=A*sin(theta)*sin(psi)-B*cos(theta)+C*cos(psi);
phi=atan(-R/S)
x=-rp*(cos(theta)*cos(phi)+sin(psi)*sin(theta)*sin(phi))*cos(alpha)-rp*(-cos(theta)*sin(phi)+sin(psi)*sin(theta)*cos(phi))*sin(alpha)+(rp/tan(alpha))*(cos(psi)*sin(phi)*(cos(alpha)-1)+cos(psi)*cos(phi)*sin(alpha));
y=-cos(psi)*sin(phi)*rp;
p=[x;y;z]
T=Rot('y',theta)*Rot('x',psi)*Rot('z',phi);
a1=T*[rp;0;0];
a2=T*[rp*cos(alpha);rp*sin(alpha);0];
a3=T*[rp*cos(beta);rp*sin(beta);0];
Con1=(p+a1)'*[0;1;0]
Con2=(p+a2)'*[-sin(alpha);cos(alpha);0]
Con3=(p+a3)'*[-sin(beta);cos(beta);0]
Any help is apperciated ! Thanks
  4 个评论
HN
HN 2020-8-27
编辑:HN 2020-8-27
Walter Roberson, sorry for incomplete information. Here it is
function output=Rot(axis,angle)
syms x y z
if axis==x
output=[1,0,0;0,cos(angle),-sin(angle);0,sin(angle),cos(angle)];
end
if axis==y
output=[cos(angle),0,sin(angle);0,1,0;-sin(angle),0,cos(angle)];
end
if axis==z
output=[cos(angle),-sin(angle),0;sin(angle),cos(angle),0;0,0,1];
end

请先登录,再进行评论。

采纳的回答

Alan Stevens
Alan Stevens 2020-8-27
This seems to work
syms rp alpha beta theta psi z
A=cos(alpha)-cos(beta);
B=sin(alpha)-sin(beta);
C=(cos(beta)-1)/tan(beta)-(cos(alpha)-1)/tan(alpha);
R=A*(cos(theta)-cos(psi))+B*cos(theta)*sin(psi);
S=A*sin(theta)*sin(psi)-B*cos(theta)+C*cos(psi);
phi=atan(-R/S);
x=-rp*(cos(theta)*cos(phi)+sin(psi)*sin(theta)*sin(phi))*cos(alpha)-rp*(-cos(theta)*sin(phi)+sin(psi)*sin(theta)*cos(phi))*sin(alpha)+(rp/tan(alpha))*(cos(psi)*sin(phi)*(cos(alpha)-1)+cos(psi)*cos(phi)*sin(alpha));
y=-cos(psi)*sin(phi)*rp;
p=[x;y;z];
T=Rot('y',theta)*Rot('x',psi)*Rot('z',phi);
a1=T*[rp;0;0];
a2=T*[rp*cos(alpha);rp*sin(alpha);0];
a3=T*[rp*cos(beta);rp*sin(beta);0];
Con1=(p+a1)'*[0;1;0];
Con2=(p+a2)'*[-sin(alpha);cos(alpha);0];
Con3=(p+a3)'*[-sin(beta);cos(beta);0];
disp([Con1; Con2; Con3])
function output=Rot(axis,angle)
syms x y z
if axis==x
output=[1,0,0;0,cos(angle),-sin(angle);0,sin(angle),cos(angle)];
end
if axis==y
output=[cos(angle),0,sin(angle);0,1,0;-sin(angle),0,cos(angle)];
end
if axis==z
output=[cos(angle),-sin(angle),0;sin(angle),cos(angle),0;0,0,1];
end
end
  6 个评论
Alan Stevens
Alan Stevens 2020-8-27
I'm afraid I don't understand your program enough to help with the derrivatives.
HN
HN 2020-8-27
syms dth dpsi
dphi=simplify(diff(phi,theta)*dth+diff(phi,psi)*dpsi);
dx1=(diff(x,theta)*dth+diff(x,psi)*dpsi+diff(x,Phi)*dphi)
:
:
It is like as shown above.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by