Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% SIR Simulation
- % Susceptible, Infected, and Resistant Simulation
- % Defines model parameters, time vector, and preallocates
- % vectors for the three populations, and defines initial conditions
- clc, clear
- Beta = 0.3;
- mu = 0.1;
- dt = 1;
- t = 0:1:600;
- S = zeros(1, 601);
- I = zeros(1, 601);
- R = zeros(1, 601);
- BetaT = zeros(1, 601);
- BetaT(1:end) = Beta;
- N = 8000000;
- R(1) = 0;
- I(1) = 1;
- S(1) = N-I(1);
- stop_length = length(t)-1;
- for i = 1:stop_length
- S(i+1) = ((-BetaT(i)*I(i)*S(i))/N)*dt+S(i);
- I(i+1) = (((BetaT(i)*I(i)*S(i))/N)-(mu*I(i)))*dt+I(i);
- R(i+1) = (mu*I(i))*dt+R(i);
- end
- hold on
- plot(t, S)
- plot(t, I)
- plot(t, R)
- legend('Susceptible Counts', 'Infected Counts', 'Resistant Counts', 'Location', 'best')
- ylabel('Counts')
- xlabel('Time(days)')
- title('SIR Counts vs. Days')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement