2 ビュー (過去 30 日間)
Saumya Nagar 17BME0447 2021 年 3 月 21 日

I am a bit new to Matlab, I have to solve the following equation for M,
A/B=(1/M)*((2/(G+1)*(1+((G-1)/2)*M^2)))^((G+1)/(2*(G-1)))
Here all the other variables than M (i.e. A, B and G) are known. I need to find the value of M. I tried out with the below code, but it did not work.
eqn=A/B-(1/M)*((2/(G+1)*(1+((G-1)/2)*M^2)))^((G+1)/(2*(G-1)))==0;
solx=solve(eqn,M)
The output came as:
solx =
root(z^6 + 15*z^4 + 75*z^2 - 432*z + 125, z, 1)
root(z^6 + 15*z^4 + 75*z^2 - 432*z + 125, z, 2)
root(z^6 + 15*z^4 + 75*z^2 - 432*z + 125, z, 3)
root(z^6 + 15*z^4 + 75*z^2 - 432*z + 125, z, 4)
root(z^6 + 15*z^4 + 75*z^2 - 432*z + 125, z, 5)
root(z^6 + 15*z^4 + 75*z^2 - 432*z + 125, z, 6)

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

### 回答 (1 件)

John D'Errico 2021 年 3 月 21 日
You need to understand that solve is a solver that will produce an analytical solution if possible. And this apparently reduces to something equivalent to a 6th degree polynomial, so there are 6 roots described. The problem is you cannot solve for a general 6th degree polynomial with the roots in an algebraic form.
What you can do is use vpa to tell MATLAB to reduce the problem to a numerical one. Try
vpa(solx)
##### 2 件のコメント表示非表示 1 件の古いコメント
John D'Errico 2021 年 3 月 21 日
Thats funny. Did I essentially tell you to write this:
solx=vpa(solx,M)
Or, this?
solx=vpa(solx)
I could swear it was the latter. In fact, when I look at my answer, that is clearly what I said. But I could be wrong.
Note that in your code, you did not even use solve. This solves for nothing:
solx=Exit_Area/Throat_Area-(1/M)*((2/(G+1)*(1+((G-1)/2)*M^2)))^((G+1)/(2*(G-1)))==0;
vpa is not solver. It merely reduces the result to a numerical form. solve and vpasolve are solvers. So you MIGHT do:
solx = solve(eqn,M);
solx = vpa(solx);
OR you might do this:
solx = vpa(solve(eqn,M));
OR you might do this:
solx = vpasolve(eqn,M);
The latter works because vpasolve is a numerical solver, so you need not apply vpa to the result.
Go slowly. Look at what you type. It will even help if you read the help for what you use. The odds will now become stronger that you get valid results.

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

### Community Treasure Hunt

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

Start Hunting!

Translated by