필터 지우기
필터 지우기

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