How to solve two differential equations using ode45

53 ビュー (過去 30 日間)
Rahula Hoop
Rahula Hoop 2019 年 8 月 8 日
回答済み: Shubham Gupta 2019 年 8 月 21 日
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 件のコメント
Shubham Gupta
Shubham Gupta 2019 年 8 月 8 日
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 2019 年 8 月 17 日
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.

サインインしてコメントする。

採用された回答

Shubham Gupta
Shubham Gupta 2019 年 8 月 21 日
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 !

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by