How to solve a function with symbolic tool

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by