Predator/Prey Model questions

3 ビュー (過去 30 日間)
Nicholas Carr
Nicholas Carr 2021 年 3 月 28 日
コメント済み: Nicholas Carr 2021 年 3 月 30 日
I'm trying to create a predator prey model with three different populations.
I was able to construct this using my notes/online tutorials, but I do not understand what all of this does (nor if I did this correctly). In my notes/ online tutorials, it seems p(1) would be the first population. I don't see where this is set up though and how it is updated. If anyone could explain how the computer reads these lines of , I'd greatly appreciate it.
function population
%initial conditions
h0=100; i0=1; v0=1;
IC=[h0,i0,v0];
t = [0 365];
B=0.07;
Ri=0.01;
Rv=0.01;
Di=0.03;
Dv=1;
Bv=0.03;
Rr=0.001;
[t,p]= ode15s(@RHS, t,IC );
figure(1)
plot(t ,p(:,1),'linewidth',2,'color','b')
hold on
plot(t ,p(:,2),'linewidth',2,'color','g')
hold on
plot(t ,p(:,3),'linewidth',2,'color','r')
grid on;
xlabel('time', 'FontSize', 20);
ylabel('Population', 'FontSize', 20);
function dpdt= RHS(t,p)
dpdt_1=(B*p(1)) - (Rv*p(1)*p(3)) - (Ri*p(1)*p(2)) + (Rr*p(2));
dpdt_2=(Ri*p(1)*p(2)) - (Di*p(2)) - (Rr*p(2));
dpdt_3=(Bv*(p(1)+p(2))*p(3))- (Dv*p(3));
dpdt=[dpdt_1;dpdt_2;dpdt_3];
end
end

採用された回答

William Rose
William Rose 2021 年 3 月 28 日
[t,p]= ode15s(@RHS, t,IC );
is where the action is in this script.
Outputs: p() is Nx3array with populations p1, p2, p3, at the N times given in the Nx1 vector t().
Inputs:
  • IC() is the vector of initial conditions. Therefore the values of [p1, p2, p3] at the initial time (t=0) are the values given in IC. Those were defined at the top to be IC=[h0, i0, v0].
  • RHS() is a function that returns a 3-element vector whose values are the time derivatives [dp1/dt, dp2/dt, dp3/dt].
  • t=[0,365] is the time range for integraiton.
  1 件のコメント
Nicholas Carr
Nicholas Carr 2021 年 3 月 30 日
Excellent, that all makes sense now. Thanks bud I appreciate the help

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

その他の回答 (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