How to solve two differential equations using ode45

43 visualizaciones (últimos 30 días)
Rahula Hoop
Rahula Hoop el 8 de Ag. de 2019
Respondida: Shubham Gupta el 21 de Ag. de 2019
My system of equations is as follows:
I need to solve these differential equations using ode45.
At t=0 the parameters have the following values: p1 = p2 = 0.25, c1 = c2 = 1, e1 = e2 = 0.7, over the interval [0,20].
The question goes on to ask which single parmeter should be changed to obtain an asymptotically stable steady state.
I am confused regarding the implementation of e and c in the formula as all other examples only have 2 variables, not 4... Help would be greatly appreciated.
Please see my Matlab script below:
clear
clc
f = @(t,y,c,e) [y(1); c(1)*y(1)*(1-y(1)) - e(1)*y(1); y(2); c(2)*y(2)*(1-y(1)-y(2)) - e(2)*y(2) - c(1)*y(1)*y(2)];
y0 = 0.25;
c(1) = 1;
c(2) = 1;
e(1) = 0.7;
e(2) = 0.7;
tspan = [0,20];
Y0 = [0.25;0.0125;0.25;-0.1125];
[T,Y,C,E] = ode45(f,tspan,Y0)
  2 comentarios
Shubham Gupta
Shubham Gupta el 8 de Ag. de 2019
Are you sure, e1,e2,c1,c2 are time-variant and not constant ? If they are time-variant then there should be differential terms of those terms too. Since, there are only two differenctial eqaution and 6 unknown these differential equations become unsolvable by conventional methods.
If e1,e2,c1,c2 are constant then we will have 2 equation and 2 unknown, which can easily be solved using ode using following model :
clear
clc
c1 = 1;
c2 = 1;
e1 = 0.7;
e2 = 0.7;
f = @(t,y) [c1*y(1)*(1-y(1)) - e1*y(1);c2*y(2)*(1-y(1)-y(2)) - e2*y(2) - c1*y(1)*y(2)];
tspan = [0,20];
Y0 = [0.25;0.25];
[T,Y] = ode45(f,tspan,Y0);
I hope it helps !
Rahula Hoop
Rahula Hoop el 17 de Ag. de 2019
Hi Shubham, your answer was perfect, thank you so much for your help!
If you would like to post your comment as an answer I'll happily select it as the solution.
Thanks again for the help, I was close but I just didn't know what to alter to make it work.

Iniciar sesión para comentar.

Respuesta aceptada

Shubham Gupta
Shubham Gupta el 21 de Ag. de 2019
Are you sure, e1,e2,c1,c2 are time-variant and not constant ? If they are time-variant then there should be differential terms of those terms too. Since, there are only two differenctial eqaution and 6 unknown these differential equations become unsolvable by conventional methods.
If e1,e2,c1,c2 are constant then we will have 2 equation and 2 unknown, which can easily be solved using ode using following model :
clear
clc
c1 = 1;
c2 = 1;
e1 = 0.7;
e2 = 0.7;
f = @(t,y) [c1*y(1)*(1-y(1)) - e1*y(1);c2*y(2)*(1-y(1)-y(2)) - e2*y(2) - c1*y(1)*y(2)];
tspan = [0,20];
Y0 = [0.25;0.25];
[T,Y] = ode45(f,tspan,Y0);
I hope it helps !

Más respuestas (0)

Categorías

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by