MATLAB: How to use subs to evaluate a symbolic matrix

matricessubs

I am trying to evaluate the pseudo-inverse of a Jacobin matrix that was computed symbolically. I use the subs command to insert the values I wanted into the resulting matrix, but I'm running into trouble getting MATLAB to actually carry through the calculations. The result is just the matrix with the numbers in the place where the syms were earlier, the actual math still having not been carried out.
My code is as follows
q1 = 1.57; %inital angles
q2 = 1.57;
q3 = 1.57;
l1 = 2; %arm lengths
l2 = 1;
l3 = 2;
syms qa qb qc la lb lc
J = jacobian([qa+qb+qc, la*cos(qa) + lb*cos(qa+qb)+ lc*cos(qa+qb+qc),la*sin(qa) + lb*sin(qa+qb)+ lc*sin(qa+qb+qc)], [qa, qb , qc]); %Creating the jacobian matrix
Jinv = pinv(J);
Jinv_eval = subs(Jinv, [qa, qb, qc, la, lb, lc],[q1, q2, q3, l1, l2, l3]); %substituting in the numerical values I want
Jinv_eval = subs(Jinv_eval);
disp(Jinv_eval);
Am I missing a command to have MATLAB carry out the calculation after making the substitutions with the subs command, or is there something more insidious going on?

Best Answer

Instead of
q1 = 1.57
use
q1 = sym('pi')/2;
and likewise for q2, q3.
But what you are missing most is vpa(Jinv_eval)