# Symbolic matrix with sine and cosine to numerical values.

25 views (last 30 days)
Boris Cnossen on 20 Sep 2020
Commented: Boris Cnossen on 20 Sep 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?

madhan ravi on 20 Sep 2020
Edited: madhan ravi on 20 Sep 2020
double(subs(T06))
%or
vpa(subs(T06))
##### 2 CommentsShowHide 1 older comment
Boris Cnossen on 20 Sep 2020
Thank you!