% This file should be saved as sir.m % This code complements that of Example_SIR_Model.m to be run in matlab. function sir =sir(t,N) % sir is the series of ordinary differential equations % works in conjuction with Example_SIR_Model.m %Parameters a = .01; % Infection rate. This parameter could be broken into the contact % rate and the probalility of infection given contact. b = .1; % Recovery rate %Differential Equations for each population sir(1) =-a*N(1)*N(2); % Susceptible sir(2) = a*N(1)*N(2)-b*N(2); % Infected sir(3) = b*N(2); % Recovered sir = [sir(1) sir(2) sir(3)]'; % SI Model % If individuals don't recover (i.e. they immediately become susceptible % after clearing the infection), then the model is an SI model. % Then, replace the above sir(1-3) with the below equations: % sir(1) = -a*y(1)*y(2) + b*y(2); % Susceptible % sir(2) = a*y(1)*y(2)-b*y(2); % Infected % If you switch this out make sure to change N0 to have only 2 values % instead of 3 and update the figure legend.