system of 3 equation with 3 unknown, with two 2nd order equation

1 Ansicht (letzte 30 Tage)
Hi,
I am trying to solve a system of 3 equation with 3 unknown, with two 2nd order equation using this code, but unfortunately I don't understand why I do not obtain the result. Thank you in advance
syms QV3 QV2 QVl
eqn1 = 17.79 == QV3 + QV2+QVl;
eqn2 = 0.25*QV3.^2 == 0.14 * QV2^2;
eqn3 = 0.25*QV3.^2 == 3.89* QVl^2;
sol = solve([eqn1, eqn2, eqn3], [QV3 , QV2, QVl])
QV3Sol = sol.QV3
QV2Sol = sol.QV2
QVLsol = sol.QVl

Akzeptierte Antwort

Star Strider
Star Strider am 23 Feb. 2020
The resuillts are strictly numerical (not containing symbolic variables), so use vpasolve instead of solve:
syms QV3 QV2 QVl
eqn1 = 17.79 == QV3 + QV2+QVl;
eqn2 = 0.25*QV3.^2 == 0.14 * QV2^2;
eqn3 = 0.25*QV3.^2 == 3.89* QVl^2;
sol = vpasolve([eqn1, eqn2, eqn3], [QV3 , QV2, QVl])
QV3Sol = sol.QV3
QV2Sol = sol.QV2
QVLsol = sol.QVl
producing:
QV3Sol =
-214.86507282291207239983881906658
6.8692131509642582629301134641865
-30.161934858502498504240076448371
8.5414023987755051080751389638705
QV2Sol =
287.1255310312749278205504662485
9.1793721884393279626540627283888
40.305580843825110030042867255874
11.413929063852511018159550534661
QVLsol =
-54.470458208362855420711647181924
1.7414146605964137744158238074247
7.6463540146773884741972091924965
-2.1653314626280161262346894985318
These are however still symbolic values. To use them in other calculations, convert them to double-precision values with the double function.
  2 Kommentare
SYML2nd
SYML2nd am 23 Feb. 2020
Thank you. Now it works. I don't understand why I can only find numerical result (I am a little bit rusty in math maybe). Why do I have 4 solution for each variable?
Star Strider
Star Strider am 23 Feb. 2020
My pleasure.
It produces strictly numerical results because they are not functions of any other symbolic variables. Any variables would appear in the vpasolve solutions if they existed (and if so, it wouild not be possible to use the double function to convert them to double-precision values).
There are 4 solutions for each variable because each variable is a -order polynomial.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by