How to convert 1x1 sym into numeric value in the workspace?
46 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Luigi Stragapede
le 9 Mai 2020
Commenté : Star Strider
le 18 Juil 2021
I need to solve this system of equations and I need to obtain the numerical value of all coefficient also in the workspace.
In order to solve this system I used:
sol = solve([eqn1, eqn2, eqn3, eqn4, eqn5, eqn6, eqn7, eqn8, eqn9, eqn10], [A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 A8 B8 A9 B9 A10 B10]);
The results in the workspace are:
How I can obtain numeric values of the coefficients? I need to put them also in the workspace.
Which is the meaning of 1x1 sym? what is the problem?
Here there is the same code if you need to try on yourself:
syms A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 A8 B8 A9 B9 A10 B10;
eqn1 = A1-B1==0;
eqn2 = A1*exp(2*3)+B1*exp(-2*3)==A2*exp(2*3)+B2*exp(-2*3);
eqn3 = A1*exp(2*3)-B1*exp(-2*3)==(1/2)*(A2*exp(2*3)+B2*exp(-2*3))+(180/2);
eqn4 = A2*exp(2*2)+B2*exp(-2*2)==A3*exp(2*2)+B3*exp(-2*2);
eqn5 = A2*exp(2*2)-B2*exp(-2*2)==(A3*exp(2*2)-B3*exp(-2*2))+(180/2);
eqn6 = A3*exp(2*3)+B3*exp(-2*3)==(4/(3^2*4^2*12*4*4i*10))*(A4*exp(4*3)-B4*exp(-4*3));
eqn7 = A3*exp(2*3)-B3*exp(-2*3)==(2/(3^2*4^2*12*4*4i*10))*(A4*exp(4*3)+B4*exp(-4*3));
eqn8 = A4*exp(4*4)+B4*exp(-4*4)==(12/2)*(A5*exp(5*4)+B5*exp(-5*4));
eqn9 = A4*exp(4*4)-B4*exp(-4*4)==(12/(2*2))*(A5*exp(5*4)-B5*exp(-5*4));
eqn10 = A5*exp(5*5)+B5*exp(-5*5)==0;
sol = solve([eqn1, eqn2, eqn3, eqn4, eqn5, eqn6, eqn7, eqn8, eqn9, eqn10], [A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 A8 B8 A9 B9 A10 B10]);
0 commentaires
Réponse acceptée
Star Strider
le 9 Mai 2020
A ‘1 x 1 sym’ is a single scalar symbolic expression, while:
Q = sym('Q', [2 3])
creates a ‘2 x 3’ symbolic expression.
If you want the numeric value of ‘A1’ (or any of the others that do not contain symbolic variables — I did not check all of them to be certain that they do not — refer to them with respect to the ‘sol’ structure:
A1d = double(sol.A1)
producing:
A1d =
0.446183616140603
.
2 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!