I am trying to simulate an epidemic model based on the SIR model. I am having trouble with my code. My graphs are not showing up like i think they should. It is not an equation error. I think there may be a problem with the storage of my values or something. Please help.
%Epidemic Simulation%Author: James Metz%Date: Nov 15, 2020%Define Natural Paramteres:p = 0.0144; %Natural Birth Rate (Davidson County)u = 0.008; %Natural Death Rate (Davidson County)f = 0.03; %Infection Rater = 0.075; %Recovery Ratem = 0.0001; %Death due to Infection Ratev = 0.092; %Vaccination Rate%Define Evaluation Time Paramteres:dt = 1; %Time increments (days)tEnd = 365; %Simulation length (days)t = 1:dt:tEnd;%Initialize Variables: I = 10; %Initial infected populationR = 0; %Initial recovered populationS = 692587; %Initial susceptible populationI_1d = zeros(1, tEnd); R_1d = zeros(1, tEnd); S_1d = zeros(1, tEnd); S_1d(1) = 692587;I_1d(1) = 10;R_1d(1) = 0; %Loop through times:for idx = 1:dt:tEnd-1 %Initialization: S = S_1d(idx); R = R_1d(idx); I = I_1d(idx); %Find changes in population numbers dS_dt = -f*S*I - S*u - S*v + S*p; %Drop in unifected population dI_dt = f*S*I - r*I - m*I - u*I; %Drop in infected population dR_dt = r*I + S*v - u*R; %Gain in Recovered population %Store new values: S_1d(idx+1) = S_1d(idx) + dS_dt; R_1d(idx+1) = R_1d(idx) + dR_dt; I_1d(idx+1) = I_1d(idx) + dI_dt; endfigure(1)subplot(2,2,1)plot(t, S_1d)xlabel('Time (days)')ylabel('Susceptible Population')title('Drop in Susceptible Population due to Infection')subplot(2,2,2)plot(t, R_1d)xlabel('Time (days)')ylabel('Recovered Population')title('Recovery Rate of Infected Persons')subplot(2,2,3)plot(t, I_1d)xlabel('Time (days)')ylabel('Infected Population')title('Infection Rate of Susceptible Persons')subplot(2, 2, 4)plot(t, S_1d, 'green')plot(t, R_1d, 'Blue')plot(t, I_1d, 'red')
This is how my graphs are turining out:
Best Answer