Symbolic matrix with sine and cosine to numerical values.

12 visualizaciones (últimos 30 días)
Boris Cnossen
Boris Cnossen el 20 de Sept. de 2020
Comentada: Boris Cnossen el 20 de Sept. de 2020
I have this code:
syms sin(q1) sin(q2) sin(q4) sin(q3) sin(q5) cos(q1) cos(q2) cos(q3) cos(q4) cos(q5) L1 L2 L3 L4 L5 L6
T01=[cos(q1) -sin(q1) 0 0;
sin(q1) cos(q1) 0 0;
0 0 1 L1;
0 0 0 1];
T12=[cos(q2) -sin(q2) 0 0;
sin(q2) cos(q2) 0 0;
0 -1 0 0;
0 0 0 1];
T23=[cos(q3) -sin(q3) 0 L2;
sin(q3) cos(q3) 0 0;
0 0 1 0;
0 0 0 1];
T34= [cos(q4) -sin(q4) 0 L4;
0 0 1 -L3-L5;
sin(q4) cos(q4) 0 0;
0 0 0 1];
T45= [cos(q5) -sin(q5) 0 0;
0 0 1 0;
sin(q5) cos(q5) 0 0;
0 0 0 1];
T56 = [0 1 0 0;
0 0 -1 -L6;
-1 0 0 0;
0 0 0 1];
T06=T01*T12*T23*T34*T45*T56;
L1 = 17; % note: all lengths are given in cm.
L2 = 17;
L3 = 7;
L4 = 4;
L5 = 4;
L6 = 9;
q1=0;
q2=pi/2;
q3=pi/2;
q4=-pi/2;
q5=0;
q6=0;
subs(T06)
//
I want to calculate the numerical values of the matrix T06. However, i am not able to that since the sine and cosine are symbolic functions now. When i use subs(T06) i then get a matrix with stuff like sin(0) and cos(0), but it doesnt calculate it but rather gives it as just sin(0) and cos(0). What can i do?

Respuestas (1)

madhan ravi
madhan ravi el 20 de Sept. de 2020
Editada: madhan ravi el 20 de Sept. de 2020
double(subs(T06))
%or
vpa(subs(T06))
  2 comentarios
madhan ravi
madhan ravi el 20 de Sept. de 2020
Instead of using syms sin(q1) and so on just declare the arguments as symbolic variables.

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