I have a 2×1 symbolic array (2×1 sym):
C = -(l1*(- l2*m2*sin(fi1 - fi2)*fidot2^2 + gr*m1*sin(fi1) + 2*gr*m2*sin(fi1)))/2 -(l2*m2*(l1*sin(fi1 - fi2)*fidot1^2 + gr*sin(fi2)))/2
here l1, l2, fi1, fi2, gr and etc. are symbolic variables.
I need to convert C symbolic array to 2×1 numeric matrix in a separate function tab in Matlab, where l1, l2, fi1, fi2 and etc. are given already.
I made a txt file with following commands:
smth=char(C); fileID = fopen('C.txt','rt'); fprintf(fileID,'%s',smth); fclose(fileID);
and it made a txt file with following content:
matrix([[-(l1*(gr*m1*sin(fi1) + 2*gr*m2*sin(fi1) - fidot2^2*l2*m2*sin(fi1 - fi2)))/2], [-(l2*m2*(gr*sin(fi2) + fidot1^2*l1*sin(fi1 - fi2)))/2]])
But, I couldn't find a way to convert it back to numeric matrix.
What could be a way to convert symbolic matrix to numeric matrix?
Best Answer