Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views2 pages

SIR Model Simulation Using Ode45

The document outlines a MATLAB script for simulating the SIR model of disease spread using the ode45 function. It defines parameters for infection and recovery rates, initial conditions for the population, and the system of differential equations. The results are plotted to show the number of susceptible, infected, and recovered individuals over a 10-day period.

Uploaded by

joshuansobila19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

SIR Model Simulation Using Ode45

The document outlines a MATLAB script for simulating the SIR model of disease spread using the ode45 function. It defines parameters for infection and recovery rates, initial conditions for the population, and the system of differential equations. The results are plotted to show the number of susceptible, infected, and recovered individuals over a 10-day period.

Uploaded by

joshuansobila19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

% SIR Model Simulation using ode45

% Parameters

a = 0.05; % Infection rate

b = 0.12; % Recovery rate

n = 200; % Total population

% Initial conditions

I0 = 1; % Initial number of infected individuals

S0 = n - I0; % Initial number of susceptible individuals

R0 = 0; % Initial number of recovered individuals

% Time span

tspan = [0 10]; % From t = 0 to t = 10

% Define the system of differential equations

sir_model = @(t, y) [

-a * y(1) * y(2); % dS/dt

a * y(1) * y(2) - b * y(2); % dI/dt

b * y(2) % dR/dt

];

% Solve the system using ode45

[t, y] = ode45(sir_model, tspan, [S0; I0; R0]);

% Plot the results

figure;

plot(t, y(:,1), 'b', 'LineWidth', 2); hold on;

plot(t, y(:,2), 'r', 'LineWidth', 2);

plot(t, y(:,3), 'g', 'LineWidth', 2);

xlabel('Time (days)');

ylabel('Number of People');

title('SIR Model of Disease Spread');

legend('Susceptible', 'Infected', 'Recovered');

grid on;

You might also like