Solving System of Equations - Complex

1 回表示 (過去 30 日間)
Articat
Articat 2020 年 7 月 8 日
コメント済み: KSSV 2020 年 7 月 8 日
I want to solve a system of equatoins. It is resulting an empty structure. Any help would be greatly appreciated!
I want to solve for: xco2, xco, xo2, xo
With these 4 unkowns I have the following 4 equations:
kp1 = (xo2^(1/2) * p^(1/2)*xco) / xco2
kp2 = (xo^2*p) / xo2
1 = xco2 + xco + xo2 + xo
1/2 = (xco2 + xco) / (xco + xo + 2*xo2)
Here is the following code:
% these are just some arbitrary values I chose for kp1, kp2, and p to see if solutoins could be solved for
kp1 = 2;
kp2 = 3;
p = 1;
syms xco2 xco xo2 xo
equation1 = (1/kp1)*((xo2^(1/2)* p^(1/2)*xco) / xco2);
equation2 = (1/kp2)*((xo^2*p) / xo2);
equation3 = xco2 + xco + xo2 + xo - 1;
equation4 = 2*((xco2 + xco) / (xco + xo + 2*xo2));
sol = solve(equation1,equation2,equation3,equation4, 'xco2 > 0', 'xco > 0'...
,'xo2 > 0', 'xo > 0');
When I type in "sol.xco" or any of the other symbols I am trying to solve for I get an empty structure which I can not explain. Any help would be greatly appreciated!

採用された回答

KSSV
KSSV 2020 年 7 月 8 日
Try this:
kp1 = 2;
kp2 = 3;
p = 1;
syms xco2 xco xo2 xo
eqns = [(xo2^(1/2)* p^(1/2)*xco)/xco2 == kp1,
(xo^2*p)/xo2 == kp2,
xco2 + xco + xo2 + xo == 1,
(xco2 + xco)/(xco + xo + 2*xo2) == 1/2] ;
sol = solve(eqns,[xco2, xco, xo2, xo])
  4 件のコメント
Articat
Articat 2020 年 7 月 8 日
I get a "Cell contents reference from a non-cell array object." error.
Perhaps I could put the equations into cell format?? I am not super familiar with cell formats but could give it a try.
KSSV
KSSV 2020 年 7 月 8 日
Okay.....actually I have octave and answering through that..I have no access to MATLAB. Might be sol is a structure.
Try sol.xo..etc.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by