I can't make A<B, it gives me 'lt' error

Hello! I am trying to make a loop with for inside a for, inside another for, but Matlab gives me this error:
Undefined function or method 'lt' for input arguments of type 'sym'
I've heard it's something about 'less than'.
I tried the program yesterday and it 'worked' (it run the program but my computer is very slow so I cancelled it before it ended, but it worked), but now I am doing the same and it gives me the error.
My loop is that:
for q1=(-185:10:185)*pi/180
for q2=(-135:10:35)*pi/180
for q3=(-120:10:158)*pi/180
J=jacobiana(q1,q2,q3,0,0,0);
D=det(J);
if abs(D)<0.05
P=tcd([q1,q2,q3,0,0,0]);
G=P*[0 0 0 1]';
x(i)=G(1);
y(i)=G(2);
z(i)=G(3);
i=i+1;
end
end
end
end

5 comentarios

Azzi Abdelmalek
Azzi Abdelmalek el 22 de Abr. de 2013
The error message concerns lt and there is no any lt in your code!
María
María el 22 de Abr. de 2013
lt is less than, and there is one '<' in the line 6
Azzi Abdelmalek
Azzi Abdelmalek el 22 de Abr. de 2013
Editada: Azzi Abdelmalek el 22 de Abr. de 2013
What do you mean?
Walter Roberson
Walter Roberson el 22 de Abr. de 2013
The "<" operator is implemented by a function named "lt".
Azzi Abdelmalek
Azzi Abdelmalek el 22 de Abr. de 2013
Ok I see

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 22 de Abr. de 2013

0 votos

What is "jacobiana" ? There is no function of that name in MATLAB or any of the toolboxes.
There is a function "jacobian", which is part of the Symbolic toolbox, and produces a symbolic output, but it uses a different calling sequence and needs to be provided with a variable name; see http://www.mathworks.com/help/symbolic/jacobian.html
You seem to be working with numeric values (unless somehow your 'pi' has become symbolic); the numeric routine most similar to "jacobian" is "gradient"

8 comentarios

María
María el 22 de Abr. de 2013
Yes, I know. It is a school work in which I have to do the jacobian without the jacob0 function, but my function jacobiana works, it isn't the problem
Please put in a breakpoint at the assignment to D, and run the program. When it stops, show
class(q1), class(q2), class(q3), class(J)
then single step (e.g., "dbstep" at the command line), and display
class(D)
if none of those show up as "sym", then single-step again and see if the comparison bombs out or not. If it does not bomb out then at the command line command
dbstop if error
and then
dbcont
This will continue running until the error occurs. At that point you can display the class() of all of the variables, and display their values. Report back your findings here.
María
María el 22 de Abr. de 2013
Ok, I have two syms: q1, q2 and q3 are double, and D and J are sym
Walter Roberson
Walter Roberson el 22 de Abr. de 2013
Okay now we need to see your jacobiana code.
María
María el 22 de Abr. de 2013
It's a bit long
function J=jacobiana(q1,q2,q3,q4,q5,q6)
syms q_1 q_2 q_3 q_4 q_5 q_6 px py pz p
%Data
d1=0.815;
d4=0.82;
d6=0.17;
a2=0.85;
a3=0.145;
%T simbolica
A_1=[cos(q_1) 0 sin(q_1) 0;sin(q_1) 0 -cos(q_1) 0;0 1 0 0.815;0 0 0 1];
A_2=[cos(q_2+(pi/2)) -sin(q_2+(pi/2)) 0 0.850*cos(q_2+(pi/2));sin(q_2+(pi/2)) cos(q_2+(pi/2)) 0 0.850*sin(q_2+(pi/2));0 0 1 0;0 0 0 1];
A_3=[cos(q_3) 0 sin(q_3) 0.145*cos(q_3);sin(q_3) 0 -cos(q_3) 0.145*sin(q_3);0 1 0 0;0 0 0 1];
A_4=[cos(q_4) 0 -sin(q_4) 0; sin(q_4) 0 cos(q_4) 0;0 -1 0 0.820;0 0 0 1];
A_5=[cos(q_5) 0 sin(q_5) 0;sin(q_5) 0 -cos(q_5) 0;0 1 0 0;0 0 0 1];
A_6=[cos(q_6) -sin(q_6) 0 0;sin(q_6) cos(q_6) 0 0;0 0 1 0.170;0 0 0 1];
Tsim=simplify(A_1*A_2*A_3*A_4*A_5*A_6);
%Jacobian's definition
A03_sim=A_1*A_2*A_3;
X=A03_sim(1,4);
Y=A03_sim(2,4);
Z=A03_sim(3,4);
fx1=diff(X,q_1);
fx2=diff(X,q_2);
fx3=diff(X,q_3);
fy1=diff(Y,q_1);
fy2=diff(Y,q_2);
fy3=diff(Y,q_3);
fz1=diff(Z,q_1);
fz2=diff(Z,q_2);
fz3=diff(Z,q_3);
%Jacobian matrix
J=[fx1 fx2 fx3;fy1 fy2 fy3;fz1 fz2 fz3];
María
María el 22 de Abr. de 2013
I think I can see a part of the problem, I erased this 3 lines at the end:
J1=[fx1 fx2 fx3;fy1 fy2 fy3;fz1 fz2 fz3];
J2=subs(J1,{q_1,q_2,q_3,q_4,q_5,q_6},
{q1*pi/180,q2*pi/180,q3*pi/180,q4*pi/180,q5*pi/180,q6*pi/180});
J=double(J2);
Without this jacobiana wasn't working right. Now D and J are double, but my computer is a bit slow for knowing if the whole program is ok
Walter Roberson
Walter Roberson el 22 de Abr. de 2013
Editada: Walter Roberson el 22 de Abr. de 2013
Why does that code not make use of the passed parameters, q1, q2, q3 ?
Possibly what you want is
J = double( subs( [fx1 fx2 fx3;fy1 fy2 fy3;fz1 fz2 fz3], {q_1, q_2, q_3, q_4, q_5, q_6}, {q1, q2, q3, q4, q5, q6}) );
Note that if that is the case, then for efficiency I would suggest calculating the symbolic matrix only once and just doing the double() of subs() the other times.
persistent J_precalc
if isempty(J_precalc)
.... your current code here, except assign to J_precalc instead of to J ...
end
J = double( subs(J_precalc, {q_1, q_2, q_3, q_4, q_5, q_6}, {q1, q2, q3, q4, q5, q6}) );
María
María el 22 de Abr. de 2013
Yes, it is working now. Thanks for all

Iniciar sesión para comentar.

Más respuestas (1)

Matt Kindig
Matt Kindig el 22 de Abr. de 2013

0 votos

Hmmm...I don't see any 'sym' variables here. What is the class() of J and P?

3 comentarios

María
María el 22 de Abr. de 2013
The program is long, I put only the loop. J is a 3x3 matrix and P is 4x4 matrix. Is that what you mean?
Matt Kindig
Matt Kindig el 22 de Abr. de 2013
And to confirm, D is a 1x1 double matrix?
María
María el 22 de Abr. de 2013
Yes

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