a MATLAB code which
sets up and solves the ordinary differential equations (ODE) which
simulate the spread of a disease
using the Susceptible/Infected/Recovered (SIR) model.
We consider the evolution of a disease epidemic in a population of
We assume that the patients can be classified as Susceptible, Infected or
Recovering, with the properties that:
Susceptible: A patient who has never been infected with the
disease. A susceptible patient can become infected, with
an infectivity coefficient alpha.
Infected: A patient who was susceptible, and has now contracted
the disease. Infected patients can spread the disease to susceptible
patients. An infected patient can become recovered, with recovery
Recovered: A patient who was infectious, but has recovered.
Such patients cannot contract the disease, and cannot transmit it.
A recovered patient can become susceptible, with
susceptibility coefficient gamma.
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
sir_ode is available in
a MATLAB version and
an Octave version and
a Python version..
Related Data and codes:
MATLAB codes which
set up various ordinary differential equations (ODE).
Models of Infection: Person to Person,
Computing in Science and Engineering,
Volume 6, Number 1, January/February 2004.
Scientific Computing with Case Studies,
Last revised on 27 October 2020.