A system of nonlinear equations with three variables
Mostrar comentarios más antiguos
Hi,
I thank you for your kind help in advance!
I am solving a system of nonlinear equations with two variable x, y, and a changing parameter T. I want to solve this problem using loop.
The description of nonlinear equations is desribed as below code:
% A changing parameters 273<T<700;
T=linespace(273,700,1000);
% two variables 0.02<x<0.2, 0.02<y<0.2
x=linespace(0.02,0.2,1000);
y=linespace(0.02,0.2,1000);
% All equations is below
% SO equation
SO = 5.8e30.*exp(-2.562./T).*((0.2-x)./(x-0.02))^(-2);
% also S has another expression
SO = 0.577.*(0.4-2.*x);
%Mo
MO = 0.6;
% yy
yy = (MO+SO)./(1-MO.*SO);
% SS equations is silimar to SO
SS = 5.8e29.*exp(-2.562./T).*((0.2-y)./(y-0.02))^(-2);
% also SS has another expression
SS = 0.577.*(0.4-2.*y);
% M equation
MM = 0.6+4.7e-5.*T;
% YY
YY= (MM+SS)./(1-MM.*SS);
% Plot a figure
plot (T-273, -2.3.*(YY-yy));
Respuesta aceptada
Más respuestas (1)
In your code, there are a few errors with matrix operations. It is more computationally to use vectorized approach instead of for .. loop operation.
% A changing parameters 273<T<700;
T=linspace(273,700,1000);
% two variables 0.02<x<0.2, 0.02<y<0.2
x=linspace(0.02,0.2,1000);
y=linspace(0.02,0.2,1000);
% SO equation (1)
SO1 = 5.8e30*exp(-2.562./T).*((0.2-x)./(x-0.02)).^(-2);
% Another expression (2): SO
SO2 = 0.577*(0.4-2.*x);
%MO
MO = 0.6;
% yy
yy = (MO+SO1)./(1-MO*SO1);
% SS equation (1)
SS1 = 5.8e29*exp(-2.562./T).*((0.2-y)./(y-0.02)).^(-2);
% Another expression (2): SS
SS2 = 0.577*(0.4-2*y);
% M equation
MM = 0.6+4.7e-5*T;
% YY
YY= (MM + SS1)./(1-MM.*SS1);
% Plot a figure
plot(T-273, -2.3.*(YY-yy));
1 comentario
Mei Cheng
el 29 de En. de 2023
Categorías
Más información sobre Systems of Nonlinear Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

