Solving system of 4 equation
Ältere Kommentare anzeigen
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));
Antworten (1)
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
Kategorien
Mehr zu Solver Outputs and Iterative Display finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!