MATLAB: Numeric solution for a set of equations

equationsnumeric solvesolve

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?

Best Answer

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.