problem using 'Solve' (return only 1 solution)

14 ビュー (過去 30 日間)
Marco Picillo
Marco Picillo 2021 年 5 月 22 日
コメント済み: Marco Picillo 2021 年 5 月 23 日
Hello,
I have a problem using solve for a symbolic expression (i'm using Matlab 2019a). I have a 3rd degree polynomial symbolic expression, and i want to find the roots.
I used:
[soluzione]=vpa(solve(equazione_gamma,CL,'Real',true))
and matlab returns:
soluzione =
0.047620242010553458040855966913202
But i expected 3 real solutions, in fact i tried using 'roots' and the solutions are:
p=[0.638 0.360 -0.860988 0.0401];
roots(p)
ans =
-1.4950e+00
8.8318e-01
4.7602e-02
(i approximated the coefficients). Seems that Matlab returns me only the last solution. What's the problem?
Thank you!

採用された回答

Andreas Apostolatos
Andreas Apostolatos 2021 年 5 月 22 日
Hi Marco,
It is not clear how you define expression 'equazione_gamma', but by reverse engineering your call to function 'roots', I believe that you define 'equazione_gamma' as '0.638*CL^3 + 0.360*CL^2 - 0.860988*CL + 0.0401' where 'CL' is a symbolic variable.
This way, the following script provides all three expected solutions in both MATLAB R2019a (both in general release and in Update 9) and MATLAB R2021a, namely,
syms CL;
equazione_gamma = 0.638*CL^3 + 0.360*CL^2 - 0.860988*CL + 0.0401;
[soluzione] = vpa(solve(equazione_gamma,CL,'Real',true))
soluzione =
0.047601767084402707714683600900841
0.8831762954368845400443443535789
-1.4950413854052997869439809325362
I hope this information helps.
Kind regards,
Andreas
  1 件のコメント
Marco Picillo
Marco Picillo 2021 年 5 月 23 日
thank you very much.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by