How to solve two differential equations using ode45
39 次查看(过去 30 天)
显示 更早的评论
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
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 !
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!