% Solve the dimensionless Lotka-Volterra equations for two sets of
% parameters and plot the results.

% Initial conditions and final time
% (used for both scenarios)
initPrey = 20;
initPredator = 20;
tFinal = 15;

% Evolve scenario 1 in time
% Anonymous function argument binds parameter values
alpha = 0.01;
beta = 0.02;
[t1, y1] = ode45(@(t,y) lvrhs(t, y, alpha, beta), ...
    [0 tFinal], [initPrey; initPredator]);

% Evolve scenario 2 in time
% New anonymous function binds new parameter values.
alpha = 0.03;
beta = 0.02;
[t2, y2] = ode45(@(t,y) lvrhs(t, y, alpha, beta), ...
    [0 tFinal], [initPrey; initPredator]);

close all

% Plot scenario 1 solution
figure
plot(t1, y1(:,1), t1, y1(:,2))
title('Solution 1')
xlabel('Time')
ylabel('Population')
legend('Prey', 'Predator')

% Plot scenario 2 solution
figure
plot(t2, y2(:,1), t2, y2(:,2))
title('Solution 2')
xlabel('Time')
ylabel('Population')
legend('Prey', 'Predator')
