Double command does not work when converting 1*1 sym variable to a numerical value. What will work?

I am having trouble converting my unknown variables, solved using the symbolic toolbox(a_1,a_2,a_3), into numerical values. the error i get is
Error using symengine (line 59)
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use VPA.
Error in sym/double (line 583)
Xstr = mupadmex('symobj::double', S.s, 0);
Heres my code:
Th_final= sym('Th_start+a_1*T*f^5+a_2*T*f^4+a_3*T*f^3')
Vel_final=sym('0== 5*a_1*T*f^4+4*a_2*T*f^3+3*a_3*T*f^2')
Acc_final=sym('0==20*a_1*T*f^3+12*a_2*T*f^2+6*a_3*T*f')
answer=solve(Th_final,Vel_final,Acc_final,'a_1','a_2','a_3');
Th_final=double(answer.a_1)
Th_final1=double(answer.a_2)
Th_final3=double(answer.a_3)
This is probably a very simple question but what command can i use to return numerical values of a_1,a_2,a_3?
Thanks

 Réponse acceptée

You cannot convert those to double. They contain the symbols Th_start, f, and T . You would need to subs() in numeric values for those symbols in order to be able to convert to double.
Note: you should remove the "0==" parts of your expressions. When you are using sym() of a string, the proper equation would be with '=' instead of '==', but you can avoid the whole issue by removing the '0==' as equality to 0 is the default condition.

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox 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!

Translated by