How can I change my code so that time series plots show oscillations, rather than steady states?

1 次查看(过去 30 天)
I am trying to model the Lotka-Volterra Predator-Prey system, using the coupled DE's:
dy(1)/dt = rx(1-x/k) - ay(1)y(2) % prey population
dy(2)/dt = aby(1)y(2) - dy(2) % predator population Here is the code I have :
%Solves equations using numerical ODE solver 45 (nonstiff runge kutta)
runtime = 1000; % Duration time of simulation in seconds.
% Parameter values used in simulation %
r = 0.5; % exponentional growth rate of prey in absence of predator
a = 0.01; % conversion efficiency of predator
b = 0.02; % attack rate
d = 0.10; % death rate
k = 750; % carrying capacity
y0 = [10, 10] % initial conditions y(1)= 10, y(2) = 10
deq1=@(t,y) [r.*y(1)*(1-(y(1)./k))- a.*y(1)*y(2); a.*b.*y(1).*y(2)- d.*y(2)];
[t,sol] = ode45(deq1,[0 runtime],y0);
How can I change my code so that time series plots (y(1) vs. time and y(2) vs. time) show oscillations, rather than steady states? It seems like something is going wrong in the integration step, as the plots are structured the way I want them but the behavior of the functions is not what I expected.
Steady state time series plots
<</
matlabcentral/answers/uploaded_files/61108/time%20series%20equilibrium.jpg>>
Phase plot reaching equilibrium

回答(1 个)

Mischa Kim
Mischa Kim 2016-10-13
编辑:Mischa Kim 2016-10-13
Charlotte, the graph above shows a plot y1 versus y2. Sort of "position" versus "velocity". In other words
plot(sol(:,1),sol(:,2))
Both y1 and y2 are showing oscillations if you plot versus time
plot(t,sol(:,1),t,sol(:,2))
In general, the oscillatory behavior of the system depends on the system parameters. So, for example, a = 0.1 results in more pronounced oscillations.
  1 个评论
Charlotte Coates
Charlotte Coates 2016-10-13
Thanks Mischa, when I plot the time series plotting y1 and y2 against time, no oscillations occur, the y1 population increases rapidly and the y2 population reaches equilibrium.
The image I posted in my question is supposed to show the y1 and y2 populations returning to their initial conditions, appearing like concentric rings in the phase plot.
I will try changing the parameter values to see if this changes, but I am not sure what else I can do to change the behavior of the functions.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by