How do I solve a system of nonlinear differential equations like the one below?

5 visualizaciones (últimos 30 días)
As seen below (ode1 ode2 ode3) are my equations and c_1 to c_9 are just some constants which will be later determined. Is there any way to solve this without numerical methods? Thank you!
syms x(t) y(t) z(t);
c_1 = 1
c_2 = 2
c_3 = 1
c_4 = 1
c_5 = 1
c_6 = 1
c_7 = 1
c_8 = 1
c_9 = 1
ode1 = diff(x,t) == c_1*(c_3-x) + c_2*(x-y);
ode2 = diff(y,t) == c_4*(x-y) - c_5*c_6*y*(1-z) + c_7*c_6*exp(c_8 - c_9*z);
ode3 = diff(z,t) == c_5*y*(1-z) - exp(c_8 - c_9*z);
odes = [ode1; ode2; ode3]
cond1 = y(0) == 0;
cond2 = x(0) == 0;
cond3 = z(0) == 0;
conds = [cond1 cond2 cond3];

Respuesta aceptada

Star Strider
Star Strider el 18 de Mzo. de 2021
Add t and Y to the syms declaration, and add these to the end of the posted code:
[VF,Subs] = odeToVectorField(odes);
odefcn = matlabFunction(VF, 'Vars',{t,Y});
Then use ‘odefcn’ with the numerical ODE integrator of your choise (such as ode45) to integrate them numerically.
Use the ‘Subs’ variable to determine the variable assignment order in the function and in the outputs of the integration.
  2 comentarios
Andrian Mirza
Andrian Mirza el 2 de Mayo de 2021
It worked very well, thanks, how to plot the results though?
Star Strider
Star Strider el 2 de Mayo de 2021
As always, my pleasure!
Try this —
syms x(t) y(t) z(t) t Y
c_1 = 1
c_1 = 1
c_2 = 2
c_2 = 2
c_3 = 1
c_3 = 1
c_4 = 1
c_4 = 1
c_5 = 1
c_5 = 1
c_6 = 1
c_6 = 1
c_7 = 1
c_7 = 1
c_8 = 1
c_8 = 1
c_9 = 1
c_9 = 1
ode1 = diff(x,t) == c_1*(c_3-x) + c_2*(x-y);
ode2 = diff(y,t) == c_4*(x-y) - c_5*c_6*y*(1-z) + c_7*c_6*exp(c_8 - c_9*z);
ode3 = diff(z,t) == c_5*y*(1-z) - exp(c_8 - c_9*z);
odes = [ode1; ode2; ode3]
odes(t) = 
[VF,Subs] = odeToVectorField(odes)
VF = 
Subs = 
odefcn = matlabFunction(VF, 'Vars',{t,Y});
[t,y] = ode45(odefcn, [0 50], zeros(1,3)+1E-8);
figure
plot(t, y)
grid
legend(string(Subs), 'Location','best')
ylim([-1 1]*5)
.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by