フィルターのクリア

Weird format of results using Matlab's Solve

8 ビュー (過去 30 日間)
Paris Pasqualin
Paris Pasqualin 2020 年 10 月 31 日
コメント済み: Paris Pasqualin 2020 年 11 月 1 日
Hello to everyone.
I have written a set of linear equations which I want to solve using Matlab solve. I define the fixed parameters, type "syms ....." containing the variables I want to solve and then type "S = solve(....)" containing the equations. Script runs without errors. When I type "S.x" to see the results for x i get values such as: 509538060020205703282156136847447614117211438890257729261961122459909435533444779743824265361881^(1/2)/719152206365557604915890126133879789423897260000 + 248683813869948514063838587/141117543058429160971820000
Is it possible to get a shorter version? I have already tried to use “format short” but results are displayed in the same way.
Has anyone else had a similar problem?
Best regards,
Paris Pasqualin

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 31 日
編集済み: Ameer Hamza 2020 年 10 月 31 日
You can use vpa() to get a floating-point answer
vpa(S.x, 10) % shows 10 digits
or get answer in MATLAB double() format
double(S.x)
  1 件のコメント
Paris Pasqualin
Paris Pasqualin 2020 年 11 月 1 日
Thanks so much for the help

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 11 月 1 日
It is the purpose of solve() to return indefinitely precise solutions when it can. You got back the exact solution, which is what solve is intended for.
If you did not want the exact solution then you should not have used solve: you should have used vpasolve().
  1 件のコメント
Paris Pasqualin
Paris Pasqualin 2020 年 11 月 1 日
Thanks for the answer. I didn't know about vpasolve() which works fine

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by