Solving system of 4 equation

I need assistance with solving these 4 equations in MATLAB as I am unsure of how to code them. Can someone please help me? It's worth mentioning that all variables, except for e1, e2, e3, and e4, are known, and K(i), k2(i), k3(i), and k4(i) are matrices consisting of 25 values.
0=((nco+v3*e1+v22*e2+v41*e4)^2*(nh2+v4*e1+v24*e2+v33*e3)^2)-(k(i)*(n0+v*e1+v03*e3+v04*e4)^2*(nch4+v1*e1+v31*e3)*(nco2+v2*e1+v23*e2+v42*e4));
0=((nco+v3*e1+v22*e2+v41*e4)*(nh2o+v21*e2)-(k21(i)*(nco2+v2*e1+v23*e2+v42*e4)*(nh2+v4*e1+v24*e2+v33*e3)));
0=((nh2+v4*e1+v24*e2+v33*e3)^2-(k31(i)*(n0+v*e1+v03*e3+v04*e4)*(nch4+v1*e1+v31*e3)));
0=((n0+v*e1+v03*e3+v04*e4)*(nco2+v2*e1+v23*e2+v42*e4)-(k41(i)*(nco+v3*e1+v22*e2+v41*e4)^2));

답변 (1개)

Torsten
Torsten 2023년 5월 19일
편집: Torsten 2023년 5월 19일

0 개 추천

Try "fsolve":
e0 = [e10;e20;e30;e40]; % initial guesses
for i = 1:25
fun = @(e1,e2,e3,e4) [((nco+v3*e1+v22*e2+v41*e4)^2*(nh2+v4*e1+v24*e2+v33*e3)^2)-(k(i)*(n0+v*e1+v03*e3+v04*e4)^2*(nch4+v1*e1+v31*e3)*(nco2+v2*e1+v23*e2+v42*e4));...
((nco+v3*e1+v22*e2+v41*e4)*(nh2o+v21*e2)-(k21(i)*(nco2+v2*e1+v23*e2+v42*e4)*(nh2+v4*e1+v24*e2+v33*e3)));...
((nh2+v4*e1+v24*e2+v33*e3)^2-(k31(i)*(n0+v*e1+v03*e3+v04*e4)*(nch4+v1*e1+v31*e3)));...
((n0+v*e1+v03*e3+v04*e4)*(nco2+v2*e1+v23*e2+v42*e4)-(k41(i)*(nco+v3*e1+v22*e2+v41*e4)^2))];
sol(i,:) = fsolve(@(x)fun(x(1),x(2),x(3),x(4)),e0);
end

댓글 수: 2

nima
nima 2023년 5월 19일
Thanks for your response but I think these equations have more than one answers for each unkonwn variables. How can I find and see the other answers?
Torsten
Torsten 2023년 5월 20일
편집: Torsten 2023년 5월 20일
You can try different initial values for the unknowns and MultiStart, but there is no guarantee to find all solutions.

댓글을 달려면 로그인하십시오.

카테고리

질문:

2023년 5월 19일

편집:

2023년 5월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by