use diff for jacobian but there is a problem

3 visualizaciones (últimos 30 días)
seonghun kim
seonghun kim el 6 de Mayo de 2018
Comentada: Star Strider el 6 de Mayo de 2018
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 comentarios
Ameer Hamza
Ameer Hamza el 6 de Mayo de 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
seonghun kim el 6 de Mayo de 2018
it doesn't work ㅠㅠ expressed same error

Iniciar sesión para comentar.

Respuestas (1)

Siyu Guo
Siyu Guo el 6 de Mayo de 2018
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 comentarios
seonghun kim
seonghun kim el 6 de Mayo de 2018
there are no theta value
Star Strider
Star Strider el 6 de Mayo de 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.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by