필터 지우기
필터 지우기

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 CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by