% sir.m 
%
% Implements an SIR infection model
% dS/dt = -beta SI
% dI/dt = beta SI - delta I
% dR/dt = delta I
%
% Inputs:
% t - Time variable: not used here because our equation 
%     is independent of time, or 'autonomous'.
% x - Independent variable: this contains three
%     populations (S, I, and R)
% Output:
% dx - First derivative: the rate of change of the populations
function dx = sir(t, x) 
  global beta delta; 

  dx = [0; 0; 0]; 

  dx(1) = -beta * x(1) * x(2); 
  dx(2) = beta * x(1) * x(2) - delta * x(2); 
  dx(3) = delta * x(2);