dn prey /dt = an prey - bn prey n predator dn predator /dt = -cn predator + dn p
ID: 3556134 • Letter: D
Question
dnprey/dt = anprey - bnpreynpredator
dnpredator/dt = -cnpredator + dnpreynpredator
where n stands for number, a is the prey growth rate, c is the predator death rate, and b and d are coefficients representing the effects of prey-predator interactions. Given a = 1.2, b = 0.6, c = 0.8, and d = 0.3. Then use ODE45 to solve for time span of 0 to 30 given the initial number of prey is 2 and the initial number of predators is 1. You should produce a plot showing the number of prey and predators as a function of time.
Explanation / Answer
function [dn ] = prey_pred( t, n )
a=1.2;
b=0.6;
c=0.8;
d=0.3;
dn(1)= a*n(1) - b*n(1).*n(2);
dn(2)= -c.*n(2) + d.*n(1).*n(2);
dn=[dn(1);dn(2)];
ode45(@prey_pred, [0,30], [2,1])
legend('prey','predators')
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.