use diff for jacobian but there is a problem
Ältere Kommentare anzeigen
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 Kommentare
Ameer Hamza
am 6 Mai 2018
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
am 6 Mai 2018
Antworten (1)
Siyu Guo
am 6 Mai 2018
1 Stimme
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 Kommentare
Star Strider
am 6 Mai 2018
Correct!
+1
Also:
theta = sym(deg2rad(-40:40));
is preferable for symbolic calculations.
Siyu Guo
am 6 Mai 2018
One more thing learnt today, :) thx
seonghun kim
am 6 Mai 2018
seonghun kim
am 6 Mai 2018
Star Strider
am 6 Mai 2018
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.
Kategorien
Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
