フィルターのクリア

How to solve a function with symbolic tool

2 ビュー (過去 30 日間)
Davide Bassignana
Davide Bassignana 2017 年 4 月 13 日
編集済み: Davide Bassignana 2017 年 4 月 13 日
I want to solve a function with symbolic math toolbox. The equation is quite simple but I can't solve it for the variale I want by hand. It should contain two function handles and one of them contain the variable I want to solve for. Here is the code:
gamma = 1.4;
M0 = 1.5;
PhiD = 0.93;
ed=0.9298;
fM =@ (M) (sqrt(gamma).*M)./(1+0.5*(gamma-1).*M^2)^((gamma+1)/(2*(gamma-1)));
syms M
f = ed*(fM(M)/fM(M0))-PhiD;
Mi=solve(f,M)
Last command returns a 1x1 sym variable and the command window displays : Mi =
root(487667696955747081*5^(1/2)*7^(1/2)*z^6 + 7315015454336206215*5^(1/2)*7^(1/2)*z^4 + 36575077271681031075*5^(1/2)*7^(1/2)*z^2 - 732792583293936200000*z + 60958462119468385125*5^(1/2)*7^(1/2), z, 1)
root(487667696955747081*5^(1/2)*7^(1/2)*z^6 + 7315015454336206215*5^(1/2)*7^(1/2)*z^4 + 36575077271681031075*5^(1/2)*7^(1/2)*z^2 - 732792583293936200000*z + 60958462119468385125*5^(1/2)*7^(1/2), z, 2)
root(487667696955747081*5^(1/2)*7^(1/2)*z^6 + 7315015454336206215*5^(1/2)*7^(1/2)*z^4 + 36575077271681031075*5^(1/2)*7^(1/2)*z^2 - 732792583293936200000*z + 60958462119468385125*5^(1/2)*7^(1/2), z, 3)
root(487667696955747081*5^(1/2)*7^(1/2)*z^6 + 7315015454336206215*5^(1/2)*7^(1/2)*z^4 + 36575077271681031075*5^(1/2)*7^(1/2)*z^2 - 732792583293936200000*z + 60958462119468385125*5^(1/2)*7^(1/2), z, 4)
root(487667696955747081*5^(1/2)*7^(1/2)*z^6 + 7315015454336206215*5^(1/2)*7^(1/2)*z^4 + 36575077271681031075*5^(1/2)*7^(1/2)*z^2 - 732792583293936200000*z + 60958462119468385125*5^(1/2)*7^(1/2), z, 5)
root(487667696955747081*5^(1/2)*7^(1/2)*z^6 + 7315015454336206215*5^(1/2)*7^(1/2)*z^4 + 36575077271681031075*5^(1/2)*7^(1/2)*z^2 - 732792583293936200000*z + 60958462119468385125*5^(1/2)*7^(1/2), z, 6)
But Mi should be a number. How can I fix it ?

採用された回答

KSSV
KSSV 2017 年 4 月 13 日
class sym can be converted to double using double.
double(Mi)
  1 件のコメント
Davide Bassignana
Davide Bassignana 2017 年 4 月 13 日
編集済み: Davide Bassignana 2017 年 4 月 13 日
Edit: it works, there are imaginary solutions but one of them is real ! thaks again !

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by