function [t,S,I,R] = Program_2_1(beta,gamma,S0,I0,MaxTime) % % % % RISK_STRUCTURE( beta, gamma, S0, I0, MaxTime) % This is the MATLAB version of program 2.1 from page 19 of % "Modeling Infectious Disease in humans and animals" % by Keeling & Rohani. % % It is the simple SIR epidemic without births or deaths.% % % Sets up default parameters if necessary. if nargin == 0 beta=1.4247; gamma=0.14286; S0=1-1e-6; I0=1e-6; MaxTime=70; end % Checks all the parameters are valid if S0<=0 error('Initial level of susceptibles (%g) is less than or equal to zero',S0); end if I0<=0 error('Initial level of infecteds (%g) is less than or equal to zero',I0); end if beta<=0 error('Transmission rate beta (%g) is less than or equal to zero',beta); end if gamma<=0 error('Recovery rate gamma (%g) is less than or equal to zero',gamma); end if MaxTime<=0 error('Maximum run time (%g) is less than or equal to zero',MaxTime); end if S0+I0>1 warning('Initial level of susceptibles+infecteds (%g+%g=%g) is greater than one',S0,I0,S0+I0); end if beta