Filter löschen
Filter löschen

How to solve SIR model with ode45?

2 Ansichten (letzte 30 Tage)
Christos Ioannou
Christos Ioannou am 14 Feb. 2021
Beantwortet: Pavan Guntha am 26 Mär. 2021
S'(t)=-λ(t)S(t) S(0)=So
Ι'(t)=λ(t)S(t)-γ(t) I(0)=Io
R'(t)=γ(t)I(t) R(0)=Ro
λ(t)=cx/N(t)*I(t)
γ(t)=1/τ

Antworten (1)

Pavan Guntha
Pavan Guntha am 26 Mär. 2021
You can refer to the following code:
[t,dYdt] = odeOut;
function [t,dYdt] = odeOut
% time dependent window
tRange = linspace(0, 10, 100); % Change the limits as per your requirement
Y0 = [S0; I0; R0]; % initial conditions
yT = 1/T; % Considering T to be a constant.
lambdaT = cx./(N(tRange).*I(tRange)); % N, I are to be defined
[t,dYdt] = ode45(@odefunc, tRange, Y0);
function dYdt = odefunc(t,y)
lambdaT_t = interp1(tRange,lambdaT,t);
dSdt = -lambdaT_t*y(1);
dIdt = lambdaT_t*y(2) - yT;
dRdt = yT*y(3);
dYdt = [dSdt; dIdt; dRdt];
end
end
You can refer to the documentation of interp1 for more details about its usage.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by