Using subplot with ode45?
Show older comments
Hi,
I need to evaluate a nonlinear ode at different values of r and then use subplot to plot them but I can't get subplot to work. Each plots on it's own just fine but the subplot piece doesn't work.
%determine the behavior of the host population in
%the absence of a parasitoid population for different
%values of r
N(1) = 20;
K = 50;
r1 = 1;
r2 = 2;
r3 = 3;
r4 = 4;
tspan = [1,1000];
N0 = 20;
[t,N] = ode45(@(t,N) N(1)*exp(r1*(1-(N(1)/K))), tspan, N0);
plot(t,N,'-o')
tspan = [1,1000];
M0 = 20;
[t,M] = ode45(@(t,M) M(1)*exp(r2*(1-(M(1)/K))), tspan, M0);
plot(t,M,'-o')
tspan = [1,1000];
G0 = 20;
[t,G] = ode45(@(t,G) G(1)*exp(r3*(1-(G(1)/K))), tspan, G0);
plot(t,G,'-o')
tspan = [1,1000];
H0 = 20;
[t,H] = ode45(@(t,H) H(1)*exp(r4*(1-(H(1)/K))), tspan, H0);
plot(t,H,'-o')
figure
subplot(2,2,1)
plot(t,N,'-o')
title('r=1)')
subplot(2,2,2)
plot(t,M,'-o')
title('r=2')
subplot(2,2,3)
plot(t,G,'-o')
title('r=3')
subplot(2,2,4)
plot(t,H,'-o')
title('r=4')
Help? :)
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!