Exponential failed Graph of SIR Model
1 回表示 (過去 30 日間)
古いコメントを表示
I need for this code to calculate in a for loop where he has to use the value of v of the day before as d(S) and has to repeat this operation for 477 times (days). This is the code that I have right now and it is suppose to return a desending exponential graph/values. Thanks for the help in advanced.
clear, clc
B = 10; % Beta = Contact Rate
r = 0.20; % Infection Rate
N_J = 2961167; % Total Population of Jamaica
A = B/N_J; % Beta Over Total Populationr
d = 10; % Duration of Infection in 1 Person
a = 1/d; % Gamma = Removal Rate
Nt = 477; % Number of Dates
I0 = 10; % Initial Infected
S0 = N_J - I0; % Initial Suceptibles
R0 = 2; % Initial Recovered
z = [1:1:477];
v = [ ]
for ii = 1:477
d(S0) = -A.*S0.*I0;
v = [v S0 + d(S0)*ii]
end
plot(v,z)
0 件のコメント
回答 (1 件)
MULI
2024 年 5 月 3 日
編集済み: MULI
2024 年 5 月 3 日
Hi Jose,
I understand that your goal is to produce a graph showing a descending exponential trend of susceptible individuals, indicating how the disease spreads through the population.
The initial code seems like infection rate is treated as static, so incorporating dynamic updates for both the infection and recovery rates is required.
To more accurately capture the exponential nature of infectious disease spread, an ‘SIR’ divides the population into three compartments (Susceptible, Infected, Recovered) and updates the counts in each compartment daily based on the transmission and recovery rates.
Typical dynamics of an SIR model, requires how the transmission rate (`beta`) and recovery rate (`gamma`) interact.
Below is the modified code incorporating these suggestions:
% Parameters
N = 2961167; % Total population
S0 = N - 10; % Initial number of susceptible individuals (assuming 10 initially infected)
I0 = 10; % Initial number of infected individuals
B = 10; % Beta = Contact Rate
d = 10; % Duration of Infection in 1 Person
R0 = 2; % Basic reproduction number
beta = B / N; % Transmission rate per individual per day
gamma = 1 / d; % Recovery rate per day
days = 477;
% Initialize arrays
S = zeros(1, days); % Susceptible
I = zeros(1, days); % Infected
R = zeros(1, days); % Recovered
S(1) = S0;
I(1) = I0;
R(1) = 0; % Initially, no one is recovered
for t = 2:days
newInfections = beta * I(t-1) * S(t-1);
newRecoveries = gamma * I(t-1);
S(t) = S(t-1) - newInfections;
I(t) = I(t-1) + newInfections - newRecoveries;
R(t) = R(t-1) + newRecoveries;
% Ensure the numbers do not exceed total population due to rounding
if S(t) < 0, S(t) = 0; end
if I(t) < 0, I(t) = 0; end
if R(t) > N, R(t) = N; end
end
% Plotting
figure;
plot(1:days, S, 'b', 'LineWidth', 2);
hold on;
plot(1:days, I, 'r', 'LineWidth', 2);
plot(1:days, R, 'g', 'LineWidth', 2);
legend('Susceptible', 'Infected', 'Recovered', 'Location', 'best');
xlabel('Days');
ylabel('Number of Individuals');
title('SIR Model Simulation over 477 Days');
grid on;
You may refer to this documentation link on SIR epidemic spread model
Hope this answers your query!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!