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 件のコメント
Ameer Hamza
2018 年 5 月 6 日
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.
seonghun kim
2018 年 5 月 6 日
回答 (1 件)
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 件のコメント
Star Strider
2018 年 5 月 6 日
Correct!
+1
Also:
theta = sym(deg2rad(-40:40));
is preferable for symbolic calculations.
Siyu Guo
2018 年 5 月 6 日
One more thing learnt today, :) thx
seonghun kim
2018 年 5 月 6 日
seonghun kim
2018 年 5 月 6 日
Star Strider
2018 年 5 月 6 日
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 についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
