フィルターのクリア

Numeric solution for a set of equations

1 回表示 (過去 30 日間)
Leandro  Cavalheiro
Leandro Cavalheiro 2016 年 9 月 25 日
コメント済み: Star Strider 2016 年 9 月 25 日
What's up, guys? I'm new to Matlab, so I apologize for my lack of knowledge. I've been trying to solve a set of 4 equations from a thermodynamics problem but I can't seem to get Matlab to work properly.
The equations are :
0.70*P = 0.35 * Psat1;
0.30*P = 0.65 * Psat2;
log (Psat1) = 13.7819 - 2726.81/(t + 217.572);
log (Psat2) = 13.9726 -3259.93/(t + 212.300);
I want to solve them for P and t (eq. 1 and 2 could eventually go into 3 and 4 thus making a 2 variable system but I chose to write the 4 eqs. anyway). I used the vpasolve function, with eq1 - eq4 being those above, but I got this:
>> syms P t Psat1 Psat2
>> vpasolve([eq1, eq2, eq3, eq4], [P t Psat1 Psat2])
ans =
P: [1x1 sym]
t: [1x1 sym]
Psat1: [1x1 sym]
Psat2: [1x1 sym]
What am I doing wrong? Is there a better function to solve this kind of problem?

採用された回答

Star Strider
Star Strider 2016 年 9 月 25 日
編集済み: Star Strider 2016 年 9 月 25 日
Try this:
syms P t Psat1 Psat2
eq1 = 0.70*P == 0.35 * Psat1;
eq2 = 0.30*P == 0.65 * Psat2;
eq3 = log(Psat1) == 13.7819 - 2726.81/(t + 217.572);
eq4 = log(Psat2) == 13.9726 -3259.93/(t + 212.300);
[P, t, Psat1, Psat2] = vpasolve([eq1, eq2, eq3, eq4], [P t Psat1 Psat2])
P =
207.45534890683278690964114324486
t =
134.10035388099313659241316466853
Psat1 =
414.91069781366557381928228648973
Psat2 =
95.748622572384363189065143036091
EDIT Added output.
  2 件のコメント
Walter Roberson
Walter Roberson 2016 年 9 月 25 日
Caution: there is a second solution with negative t and the other values on the order of 10^53 . vpasolve() might find either of them unless you add a restriction to the range. For example,
syms P t Psat1 Psat2 positive
Star Strider
Star Strider 2016 年 9 月 25 日
@Walter — Excellent point. When the solutions I got seemed reasonable, I didn’t explore the complete solution space.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by