MATLAB Answers

Issue with SEIR model for mathlab

100 views (last 30 days)
Jacobo CHoy
Jacobo CHoy on 20 Mar 2020
Commented: charles aouad on 23 Mar 2020
I am quite new in mathlab and i am trying to test the SEIR model but i can not get it to run. I have problems when i try to run the code.
I am using this github repository to calculate it. and also this file from the fileexchange
I have tried to run the example 3 ( in the github ) with all the files but when I run it I get the output :
Error using SEIQRDP
Too many input arguments.
Error in example3 (line 38)
[S,E,I,Q,R,D,P] = SEIQRDP(alpha1,beta1,gamma1,delta1,Lambda1,Kappa1,Npop,E0,I0,Q0,R0,D0,t);
I put the example 3 file below,
maybe you can help me find the issue? It might be very simple...
The example 3 file.
clearvars;close all;clc;
indLocation = find(contains(tableRecovered.CountryRegion,'Italy')==1)
indLocation = indLocation(1)
Recovered = table2array(tableRecovered(indLocation,5:end));
Deaths = table2array(tableDeaths(indLocation,5:end));
Confirmed = table2array(tableConfirmed(indLocation,5:end));
% If the number of confirmed Confirmed cases is small, it is difficult to know whether
% the quarantine has been rigorously applied or not. In addition, this
% suggests that the number of infectious is much larger than the number of
% confirmed cases
minNum= 40;
time(Confirmed<=minNum)= [];
Npop= 120e6; % population
guess = [0.06,1.2,1/5,1/40,0.01,0.02,0.01,0.02]; % my guess for the fit
E0 = Confirmed(1); % Initial number of exposed cases (we do not know it, so it is set at zero)
I0 = Confirmed(1); % Initial number of infectious cases (we do not know it, so it is the number of quarantined)
Q0 = Confirmed(1);
R0 = Recovered(1);
D0 = Deaths(1);
[alpha1,beta1,gamma1,delta1,Lambda1,Kappa1] = ...
dt = 0.1; % time step
time1 = datetime(time(1)):dt:datetime(2020,3,25,0,0,0);
N = numel(time1);
t = [0:N-1].*dt;
[S,E,I,Q,R,D,P] = SEIQRDP(alpha1,beta1,gamma1,delta1,Lambda1,Kappa1,Npop,E0,I0,Q0,R0,D0,t);
hold on
% ylim([0,1.1*Npop])
ylabel('Number of cases')
xlabel('time (days)')
% leg = {'susceptible','exposed','infectious','quarantined','recovered','Dead','insusceptible'};
leg = {'Quarantined (confirmed infectious)','recovered','Dead'};
grid on
axis tight
% ylim([1,8e4])


Sign in to comment.

Accepted Answer

E. Cheynet
E. Cheynet on 21 Mar 2020
I am not able to reproduce your error. The file is running normally on my Matlab version, both with a live script and a normal script. I see one possibility for the error you have: you use an older version of SEIQRDP. Previous versions of SEIQRDP accepted less inputs than the new one.


Show 2 older comments
charles aouad
charles aouad on 23 Mar 2020
ok i think it is a license problem i dont have the lsqcurvefit tool
is there a way to go around this?or i need to buy it?
i use r2018a
thanking you in advance for your help
Feature: Optimization_Toolbox
License path: C:\Users\user\AppData\Roaming\MathWorks\MATLAB\R2018a_licenses\license_DESKTOP-29BVPTL_40680735_R2018a.lic;C:\Program
Files\MATLAB\R2018a\licenses\license.dat;C:\Program Files\MATLAB\R2018a\licenses\*.lic
Licensing error: -5,357.
Error in fit_SEIQRDP (line 69)
[Coeff] = lsqcurvefit(@(para,t) modelFun1(para,t),...
Error in seim (line 23)
[alpha1,beta1,gamma1,delta1,Lambda1,Kappa1] = fit_SEIQRDP(Q,R,D,Npop,E0,I0,time1,guess);
Jacobo CHoy
Jacobo CHoy on 23 Mar 2020
I am using a trial of MATLAB online. Your issue has probably to do with the version. The problem i had and solved it was just using the latest files available without modifying them at first. Just downloading the raw .mlx and .m files and just clicking run.
Maybe you could use the software online if you have the license? Or maybe download the latest version. I am using r2020a
charles aouad
charles aouad on 23 Mar 2020
Hi jacobo Thanx for your reply I am using r2018 I will try again, maybe this command only works for 2020 release?

Sign in to comment.

More Answers (0)

Translated by