How to convert 1x1 sym into numeric value in the workspace?

50 次查看(过去 30 天)
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]);

采纳的回答

Star Strider
Star Strider 2020-5-9
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
.

更多回答(1 个)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020-5-9
编辑:KALYAN ACHARJYA 2020-5-9

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by