In my problem, there are some matrices like
T_x=[ cos(q1) sin(q1+q2) cos(q1) -sin(q2);
0 0 1 -1;
sin(q4) 0 1 q1;
0 0 0 1]
Moreover I have the q
values such as: q=[0.2 0.05 -2 -3.5]
How can I insert the q
values into T_x
matrix?
Thanks
One way would be to have a matrix-returning function that takes the values as an argument:
>> T_x = @(q) [ cos(q(1)) sin(q(1)+q(2)) cos(q(1)) -sin(q(2));
0 0 1 -1;
sin(q(4)) 0 1 q(1);
0 0 0 1];
>> T_x([.2 .05 -2 -3.5])
ans =
0.9801 0.2474 0.9801 -0.0500
0 0 1.0000 -1.0000
0.3508 0 1.0000 0.2000
0 0 0 1.0000
This has the benefit of not needing the symbolic package - it's portable to Octave.