How can I change my code so that time series plots show oscillations, rather than steady states?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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
<</
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/157110/image.jpeg)
matlabcentral/answers/uploaded_files/61108/time%20series%20equilibrium.jpg>>
Phase plot reaching equilibrium
2 Commenti
David Goodmanson
il 13 Ott 2016
Take a look at what happens if you increase the carrying capacity to, say, 1e6.
Risposte (1)
Mischa Kim
il 13 Ott 2016
Modificato: Mischa Kim
il 13 Ott 2016
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.
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!