File Exchange

image thumbnail

SIR Epidemic Spread Model

version 1.0.0 (55.8 KB) by Giovanni Valentini
This is a live script that explores the SIR model in order to simulate the spread of a virus over time.


Updated 18 Apr 2020

View License

The SIR model has been developed in the past years to simulate the spread of a virus over time. The script includes a brief introduction, in which the model is presented, and the code to run the simulation of the epidemic over time. Two cases are analysed: one without immunity loss, where recovered individuals don't get infected again, and one with immunity loss.

Cite As

Giovanni Valentini (2021). SIR Epidemic Spread Model (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (10)

Adib Jamel

where to find this article

Hannah Abrahams

Bangdong Zhi

Sandra Marium Kurien

sir can u pls share the code

Sir I need the function file sir_model.m. please share it..... Thank you in advance

Akanksha Verma

can you share the function file ( sir_model.m)??

Yimin Wang

It might be better to scale the model by population size N.
% Equations of the model
dS = (-beta*I(tt)*S(tt)/N + delta*R(tt)) * dt;
dI = (beta*I(tt)*S(tt)/N - gamma*I(tt)) * dt;
dR = (gamma*I(tt) - delta*R(tt)) * dt;

Mel Lieberman

Easy to use code with no apparent bugs

Ajinkya Jadhav

Mariana Nagy

MATLAB Release Compatibility
Created with R2020a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!