use diff for jacobian but there is a problem

syms x y z theta; a=90; b=122; t=50; v=[x y theta];
L1=sqrt(((-a/2*cosd(theta)-((b+t)*sind(theta))+x+1000).^2)+(-a/2*sind(theta)+(b+t)*cosd(theta)+y-1072).^2); Lx=diff(L1,x) Ly=diff(L1,y) Ltheta=diff(L1,theta)
L2=sqrt(((a/2*cosd(theta)-(b+t)*sind(theta)+x-1000).^2)+(a/2*sind(theta)+(b+t)*cosd(theta)+y-1072.)^2); Lx2=diff(L2,x) Ly2=diff(L2,y) Ltheta2=diff(L2,theta)
L3=sqrt(((b+t)*sind(theta)-x).^2+((1072-(b+t)*cosd(theta)-y).^2)+(1100+a/2).^2); Lx3=diff(L3,x) Ly3=diff(L3,y) Ltheta3=diff(L3,theta)
x=(-20:0.5:20); y=(-40:40); theta=(-40:40);
J=[Lx Ly Ltheta;Lx2 Ly2 Ltheta2;Lx2 Ly2 Ltheta3] J=det(A)
%the error is 함수 'cosd'은(는) 'sym'형 입력 인수에 대해 정의되지 않았습니다. function 'cosd' is not defined as inputted factor 'syms'

2 个评论

I just ran your code and it is working fine. Can you run this line
which cosd
to see if this is problem with MATLAB paths.
it doesn't work ㅠㅠ expressed same error

请先登录,再进行评论。

回答(1 个)

I think MATLAB does not recognize the function "cosd" in its symbolic computations. You should instead use "cos", which means you need to convert your x value from degrees to rads. When you substitute the symbolic variable x with some specific values, make sure the values are in rads rather than degrees. For example, replace the "cosd" and "sind" in your code with "cos" and "sin", and use "theta = deg2rad(-40:40)" rather than "theta = -40:40" to evaluate the expressions.

5 个评论

Correct!
+1
Also:
theta = sym(deg2rad(-40:40));
is preferable for symbolic calculations.
One more thing learnt today, :) thx
which position "theta = sym(deg2rad(-40:40));" should go? under the" syms x y z theta; a=90; b=122; t=50; v=[x y theta];"?
Put it just after the initial syms call, and use sym for the other numeric constants as well.
It would be appropriate for you to Accept Siyu Guo’s Answer.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by