I have an init script with some symbols declared:
syms q1 q2 q3 q4 q5 q6
This script calls a function, where I try to build a matrix that depends on those symbols:
function angular_jacobian(T,n,joint,q) JA(:,1) = [0; 0; 1]; for i=2:n if joint(i) == 'p' JA(:,i) = [0; 0; 0]; else disp(T(1:3,3,i-1)); JA(:,i) = simplify(T(1:3,3,i-1)); end end disp(JA);end
where T is a vector of 4×4 matrices. I'm just trying to build a 3xN matrix, called JA, that has first column [0;0;1], and then all the others equal to a column of zeros or to T(1:3,3,i-1). The error I get is the following:
The following error occurred converting from sym to double:Unable to convert expression into double array.
This happens only if T(1:3,3,i-1) has symbols in it (I tried with scalar T(1:3,3,i-1) and it works). Of course every matrix T(1:3,3,i-1) has only declared symbols (I built T with other functions).
Does anybody know what I am ignoring? I have actually no idea.
Best Answer