Solving (non-linear equation) for a single unknown?

7 vues (au cours des 30 derniers jours)
Juan Murcia
Juan Murcia le 5 Oct 2020
I have this nonlinear equation and I need to find the value of Ms.
a1/a4= 1
P4 = 0.448159;
P1= 0.101325;
γ=1.4;
I was trying to solve it this way but it is obviously wrong.
syms M
P4 = 0.448159
P1= 0.101325
y=1.4
equ1 = P4/P1 == [(2*y/(y+1))*M^2-(y-1)/(y+1)]*[1-((y-1)/(y+1))*(M-1/M)]^-(2*y/(y-1));
[M] = fzero([equ1],[M])

Réponse acceptée

John D'Errico
John D'Errico le 5 Oct 2020
Modifié(e) : John D'Errico le 5 Oct 2020
syms are a set of tools written to solve symbolic problems. fzero is a tool to solve numerical problems. The gray area between is an unfriendly place, inhabited by mainly scary trolls and other monsters who live under bridges and beds.
Having said that, you could have solved it either way. You just needed to decide which side of the bridge you want to walk on.
First, how might I try to solve it using syms? First,
a1/a4 =1
has no meaning as an assignment in MATLAB. so I hope you built that into the equation.
syms M
P4 = 0.448159
P1= 0.101325
y = 1.4
equ1 = -P4/P1 + [(2*y/(y+1))*M^2-(y-1)/(y+1)]*[1-((y-1)/(y+1))*(M-1/M)]^-(2*y/(y-1));
Note that Iwrote it as not an equality, but as a simple expression. Root finding tools will implicitly try to solve for a zero anyway, but this allows me to plot it, to see and understand what is happening.
Next, PLOT YOUR PROBLEMS. PLOT EVERY THING! Then find something else to plot, some other way to plot it.
fplot(equ1,[0,2])
This shows me a root exists around M=1.4. Some singularities seem to exst a little below zero, and up around 6. But the root you would care about is probably around 1.4 or so.
vpasolve(equ1,M,1.4)
ans =
-0.10185626363218756417257616328639
1.3679197596493595518736224716577
- 0.29798382430301867914089211801632 - 0.10655492772947358270800196360489i
- 0.29798382430301867914089211801632 + 0.10655492772947358270800196360489i
- 0.13167891856268140659782656510051 - 0.089020165945488844111776993803467i
- 0.13167891856268140659782656510051 + 0.089020165945488844111776993803467i
- 0.10644518860890615670084999757915 + 0.036618213906838787751435372728374i
- 0.10644518860890615670084999757915 - 0.036618213906838787751435372728374i
0.21399593206465125085994080997702 - 2.5850229905649044544862013343752i
0.21399593206465125085994080997702 + 2.5850229905649044544862013343752i
5.2154139367256047527277605369217 + 9.7387628639309747245175842995618i
5.2154139367256047527277605369217 - 9.7387628639309747245175842995618i
15.473666314675764245001344179612 + 5.761291040160465785371267286251i
15.473666314675764245001344179612 - 5.761291040160465785371267286251i
And vpasolve found a root at 1.3679... As well as some other solutions that are probably not very interesting.
Alternatively, you could live in the numerical domain.
equ1 = @(M) -P4/P1 + [(2*y/(y+1))*M^2-(y-1)/(y+1)]*[1-((y-1)/(y+1))*(M-1/M)]^-(2*y/(y-1));
format long g
fzero(equ1,[0,2])
ans =
1.36791975964936
Whatever floats your boat...

Plus de réponses (1)

Star Strider
Star Strider le 5 Oct 2020
If you want to use the Symbolic Math Toolbox for this, use solve not fzero:
syms M
P4 = 0.448159
P1= 0.101325
y=1.4
equ1 = P4/P1 == [(2*y/(y+1))*M^2-(y-1)/(y+1)]*[1-((y-1)/(y+1))*(M-1/M)]^-(2*y/(y-1));
Ms = solve(equ1,M);
Msv = vpa(Ms)
producing:
Msv =
-0.10185626363218756417257616328639
- 0.10644518860890615670084999757915 - 0.036618213906838787751435372728374i
- 0.10644518860890615670084999757915 + 0.036618213906838787751435372728374i
- 0.13167891856268140659782656510051 - 0.089020165945488844111776993803467i
- 0.13167891856268140659782656510051 + 0.089020165945488844111776993803467i
- 0.29798382430301867914089211801632 - 0.10655492772947358270800196360489i
- 0.29798382430301867914089211801632 + 0.10655492772947358270800196360489i
1.3679197596493595518736224716577
0.21399593206465125085994080997702 - 2.5850229905649044544862013343752i
0.21399593206465125085994080997702 + 2.5850229905649044544862013343752i
5.2154139367256047527277605369217 - 9.7387628639309747245175842995618i
5.2154139367256047527277605369217 + 9.7387628639309747245175842995618i
15.473666314675764245001344179612 - 5.761291040160465785371267286251i
15.473666314675764245001344179612 + 5.761291040160465785371267286251i
.

Catégories

En savoir plus sur Stability Analysis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by