Converting 2x1 Symbolic array to 2x1 Numeric matrix in Matlab
Afficher commentaires plus anciens
I have a 2x1 symbolic array (2x1 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 2x1 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?
1 commentaire
madhan ravi
le 10 Fév 2019
See about subs().
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Common Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!