clear figure N = 200; S = 990; I = 10; R = 0; coeffs = options; coeffs.InfectionRate = 0.02; coeffs.ImmunisationRate = 0.029; coeffs.ImmunisationLossRate = 2.7e-4; coeffs.DeathRate = 1.3e-2; coeffs.NaturalDeathRate = 2e-5; coeffs.NatalityRate = 5e-5; VaccinationVector = build_vacc_rate(2.4e-4, 2.4e-3, 50, N); % VaccinationVector = build_vacc_rate(0, 0, 50, N); model = model(S, I, R, 12, N); t = 1:N; for i=t model.step(i, coeffs, VaccinationVector); end % figure % hold on % plot(t, Slist); % plot(t, Ilist); % plot(t, Rlist); % plot(t, Dlist); area([model.Slist.', model.Wlist.', model.Ilist.', model.Rlist.']); legend('Susceptible', 'Waiting', 'Infected', 'Immunized'); title('Evolution of virus in population'); xlabel('Time'); ylabel('Population'); axis([1, N, 0, inf]); % utility functions function vacc_rate=build_vacc_rate(start_rate, end_rate, change_step, N) vacc_rate = zeros(1, N); for i=1:change_step vacc_rate(i) = start_rate; end for i=change_step+1:N vacc_rate(i) = end_rate; end end