From 07e3b7e5dbb9ccee6160c1ebfb7f961baac7c806 Mon Sep 17 00:00:00 2001 From: Paul CACHEUX <paulcacheux@gmail.com> Date: Wed, 23 May 2018 14:22:02 +0200 Subject: [PATCH] Suppression des /N aux mauvais endroits --- SRI_matlab/main.m | 6 +++--- SRI_matlab/step.m | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SRI_matlab/main.m b/SRI_matlab/main.m index bd93d8c..ac9f50d 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 067cd39..8cb17c9 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 -- GitLab