Matlab recommends me to apply 'subs' command but I have already used it to convert a symbolic matrix into a numerical one. What fails?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dear all,
I am trying to obtain the eigenvalues of a matrix which was previously defined with symbolic variables. Here is a bit of the code:
P_simb=[Cf_ss Lo_ss Ro_ss omega_b_ss Tgt_ss K_q_ss K_d_ss Ta_ss K_w_ss omega_g0_ss omega_f_ss Kp_ex_ss Ki_ex_ss Tex_ss vkd_ss vkq1_ss Rs_ss L1_ss Lmd_ss Lmq_ss Rfd_ss Lfd_ss Rkd_ss Lkd_ss Rkq1_ss Lkq1_ss Lf1d_ss Rdamp_ss ism_d_ss ism_q_ss ifd_ss ikd_ss ikq1_ss vo_d_ss vo_q_ss omega_sm_ss deltathetasm_ss pm_ss vfd_ss];
P_num=[1e-5 0.2 0.01 314.15926 0.5 0 0 2 20 1 1000 0.02353 0.005028 0.1 0 0 0.004044 0.0545 1.117 0.4772 8.476e-4 0.256 0.041 0.288 0.02859 1.1948 1.117 6.6666666e2 1 0 1 1 0 1 0 1 0 0.5 1];
A_num=subs(A_simb, P_simb, P_num);
A_final=double(A_num);
eig_A=eig(A_final)
plot(real(eig_A),imag(eig_A),'x',"markersize",15);
However, despite of having used 'subs' command, I obtain the following errors:
"Error using symengine
Unable to convert expression containing symbolic variables into double array. Apply 'subs' function first to substitute
values for variables.
Error in sym/double (line 800)
Xstr = mupadmex('symobj::double', S.s, 0);
Error in VSM_baseline (line 178)
A_final=double(A_num);"
*First of all, I feel sorry that I cannot share the symbolic matrix A, since it comes from a very long set of equations that would extend excessively the content of this question.
Anyway, could someone give me an advice on how to fix this issue? I have read many many previous similar threads without sucess. Besides, the error message seems very inconsistent as I already applied 'subs' command in previous lines....
And the following is also very weird. Although A_num is categorised by Matlab as a symbolic matrix, A_num actually has numeric values and it is even possible to perform matrix operations with it....
0 Commenti
Risposta accettata
Paul
il 22 Gen 2022
It looks like there is still one or sym objects left in A_num after the command
A_num = subs(A_simb, P_simb, P_num);
What is the output of this command
symvar(A_num)
if you execute it just after that call to A_num = subs(..... ?
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Assumptions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!