フィルターのクリア

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

79 ビュー (過去 30 日間)
Luigi Stragapede
Luigi Stragapede 2020 年 5 月 9 日
コメント済み: Star Strider 2021 年 7 月 18 日
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
.
  2 件のコメント
Ankit kumar
Ankit kumar 2021 年 7 月 18 日
ya thanks , it solved my problem
Star Strider
Star Strider 2021 年 7 月 18 日
@Ankit kumar My pleasure!

サインインしてコメントする。

その他の回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 5 月 9 日
編集済み: KALYAN ACHARJYA 2020 年 5 月 9 日
  1 件のコメント
Luigi Stragapede
Luigi Stragapede 2020 年 5 月 9 日
I tried to used double but it doesn't work:
for example:
A1=double(A1); but nothing

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by