function sir_continuous ( t0, tmax, k_user, tau_user )

%*****************************************************************************80
%
%% sir_continuous() uses ode23() to produce a solution of the SIR model.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 April 2009
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T0, TMAX
%
%    real K_USER,
%
%    real TAU_USER
%
  global k
  global tau

  k = k_user;
  tau = tau_user;

  tspan = [ t0, tmax ];

  y0 = [ 0.995, 0.005, 0.000 ];

  [ tout, yout ] = ode23 ( @epidemic, tspan, y0 );

  plot ( tout, yout(:,1), 'g', ...
         tout, yout(:,2), 'r', ...
         tout, yout(:,3), 'k', 'LineWidth', 2 );

  return
end
function dydt = epidemic ( t, y )

%*****************************************************************************80
%
%% epidemic() returns the right hand side of the SIR differential equations.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 April 2009
%
%  Author:
%
%    John Burkardt
%
  global k
  global tau

% tau = 0.8;
% k = 4;

  S = y(1);
  I = y(2);
  R = y(3);

  dydt(1,1) = - tau * I * S;
  dydt(2,1) =   tau * I * S - I / k;
  dydt(3,1) =                 I / k;

  return
end
 
