How to solve 4 equations with 4 unknowns using matlab
9 ビュー (過去 30 日間)
古いコメントを表示
I'm attempting to use matlab to solve a set of 4 nonlinear equations with 4 unknowns. This is what I've entered so far, but it keeps saying it cant find a solution. Any suggestions?
mf=.12;
Yfin=.0826;
Kg=(6.19*10^9)*exp(-15098/298);
MW=29;
V=.000268;
P=101325;
R=8315;
M=.1;
N=1.65;
Yoxin=.9174;
AF=16;
Hf=40000000;
Cp=1200;
Tin=298;
eqn1='mf*(Yfin-R1)-Kg*MW*V*((P/R*R2)^(M+N))*(((R1^M)*((.233*R3)^N))/1)'
eqn2='mf*(Yoxin-R1)-(AF)*Kg*MW*V*((P/R*R2)^(M+N))*(((R1^M)*((.233*R3)^N))/1)'
eqn3='1-R1-R3-R4'
eqn4='(R1-Yfin)*Hf+Cp*(R2-Tin)'
sol=fsolve(eqn1,eqn2,eqn3,eqn4,'R1','R2','R3','R4')
3 件のコメント
Walter Roberson
2013 年 11 月 21 日
The fsolve() syntax you are using would be the syntax for solve(), a symbolic solver, rather than fsolve(), a numeric solver. If you want to use the symbolic solver, you should use
syms R1 R2 R3 R4
and then when you define your equations, do not put in the quotation marks,
eqn1 = mf*(Yfin-R1)-Kg*MW*V*((P/R*R2)^(M+N))*(((R1^M)*((.233*R3)^N))/1);
and so on. And change to solve()
採用された回答
Roger Stafford
2013 年 11 月 21 日
I suggest you try to solve it numerically using 'fsolve' rather than symbolically.
3 件のコメント
Roger Stafford
2013 年 11 月 21 日
The 'fsolve' function is found in the Optimization Toolbox. You can read about it at:
http://www.mathworks.com/help/optim/ug/fsolve.html
It requires that you make an initial estimate of a solution and it attempts to converge to an accurate solution. If there are many roots, it will be necessary to use many initial estimates in order to find them all. It uses matlab's usual double precision numbers rather than the symbolic forms used by 'solve'. It does require that you specify the numerical values of all parameters involved but you have satisfied that requirement.
その他の回答 (2 件)
Walter Roberson
2013 年 11 月 21 日
You will probably not be able to find a meaningful numeric solution. The gradient of the function is very very steep, and outside a very narrow valley of R3 values it goes complex. The width of the range of R3 values that lead to non-complex values is less than eps() of the representable value, so numerically you are always going to end up with complex results if you using "double". You can get meaningful results if you work symbolically with more than 150 digits of precision.
R1 is on the order of 8 * 10^(-12), R2 is on the order of 3051 1/3, R3 is on the order of 8336.5; and because of the constraint that 1-R1-R3-R4 = 0, R4 comes out approximately -8335.5
0 件のコメント
Alex Sha
2019 年 10 月 12 日
r1: 0.0269466666666667
r2: 2153.11111111111
r3: 2523.94560037811
r4: -2522.97254704477
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!