diff --git a/SRI_matlab/main.m b/SRI_matlab/main.m index bd93d8cf516aa48ba968507cecbc67c7b85281a8..ac9f50d13a54bb2a9cb13d19d9acc2511e61dcdb 100644 --- a/SRI_matlab/main.m +++ b/SRI_matlab/main.m @@ -16,7 +16,7 @@ coeffs.DeathRate = 0.04; coeffs.NaturalDeathRate = 0.002; coeffs.NatalityRate = 0.003; -N = 10000; +N = 30; Slist = zeros(1, N); Ilist = zeros(1, N); @@ -25,10 +25,10 @@ Rlist = zeros(1, N); t = 1:N; for i=t - input = step(input, coeffs); Slist(i) = input(1); Ilist(i) = input(2); Rlist(i) = input(3); + input = step(input, coeffs) end % figure @@ -43,4 +43,4 @@ legend('Susceptible', 'Infected', 'Immunized'); title('Evolution of virus in population'); xlabel('Time'); ylabel('Population'); -% axis([1, N, 0, n_pop]); \ No newline at end of file +axis([1, N, 0, inf]); \ No newline at end of file diff --git a/SRI_matlab/step.m b/SRI_matlab/step.m index 067cd39ee0071189a57e1837599d9d6009a349c1..8cb17c9884d2df624f5e0d61f2fa5a865765ca3d 100644 --- a/SRI_matlab/step.m +++ b/SRI_matlab/step.m @@ -5,9 +5,9 @@ R = X(3); N = S + I + R; -dS = -options.InfectionRate * S * I / N - options.VaccinationRate * S / N + options.ImmunisationLossRate * R + options.NatalityRate - options.NaturalDeathRate * S/N; -dI = options.InfectionRate * S * I / N - options.ImmunisationRate * I - options.DeathRate * I; -dR = options.ImmunisationRate * I + options.VaccinationRate * S / N - options.ImmunisationLossRate * R - options.NaturalDeathRate * R/N; +dS = -options.InfectionRate * S * I/N - options.VaccinationRate * S + options.ImmunisationLossRate * R + options.NatalityRate - options.NaturalDeathRate * S; +dI = options.InfectionRate * S * I/N - options.ImmunisationRate * I - options.DeathRate * I; +dR = options.ImmunisationRate * I + options.VaccinationRate * S - options.ImmunisationLossRate * R - options.NaturalDeathRate * R; -res = [S + dS, I + dI, R + dR]; +res = [max(S + dS, 0), max(I + dI, 0), max(R + dR, 0)]; end \ No newline at end of file