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개)

Siyu Guo
Siyu Guo 2018년 5월 6일

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.
Siyu Guo
Siyu Guo 2018년 5월 6일
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];"?
there are no theta value
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2018년 5월 6일

댓글:

2018년 5월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by