how i solve Approciman​tCoefficie​ntsSIR in MATLAB

4 ビュー (過去 30 日間)
MOHAN D
MOHAN D 2021 年 12 月 3 日
回答済み: Walter Roberson 2025 年 4 月 1 日
I want to solve the approximantcoefficientsSIR,but it keep showing the error in line4
alpha=2.73; r=0.0178; I0=7; S0=254; %input parameters
t=0:0.01:6; %time interval 0 to 6 in increments of 0.01
N=25; %number of terms in the approximant, increase until answer stops changing
[A,Sinf,a0,a]=ApproximantCoefficientsSIR(N,alpha,r,S0,I0);
Unrecognized function or variable 'ApproximantCoefficientsSIR'.
kappa=r*Sinf-alpha;
Ssum=1;
for j=1:N
Ssum=Ssum+A(j)*exp(kappa*t*j); %approximant (equation 4.7a in paper)
end
S=Sinf./Ssum;
plot(t,S,'displayname','S'); hold on
I=alpha/r*log(S/S0)+S0-S+I0;
plot(t,I,'displayname','I');
R=S0+I0-S-I; %b/c S+I+R=constant
plot(t,R,'displayname','R'); xlabel('t'); legend show

回答 (2 件)

TARUN
TARUN 2025 年 4 月 1 日
編集済み: TARUN 2025 年 4 月 1 日
Make sure that ApproximantCoefficientsSIR for approximating the coefficients of the SIR model, is properly installed in MATLAB.
You can run “which ApproximantCoefficientsSIR” command in MATLAB to check if the function is recognized and correctly installed.
Alternatively, you can use ode45 to solve the SIR model.
Feel free to go through this answer to get an idea on how to use ode45to solve SIR model:
Learn more about ode45 here:

Walter Roberson
Walter Roberson 2025 年 4 月 1 日
approximantcoefficientsSIR requires the installation of a File Exchange contribution https://www.mathworks.com/matlabcentral/fileexchange/75131-approximantcoefficientssir

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by