Not enough input arguments.

1 visualización (últimos 30 días)
Cumpaniciu Alexandru
Cumpaniciu Alexandru el 24 de Mayo de 2020
Editada: Cumpaniciu Alexandru el 26 de Mayo de 2020
HI,I am new to Matlab and I am trying this code,but it is not working...
Where is the problem?
Not enough input arguments.
Error in ebolab (line 40)
x=lsqcurvefit( @Model_Inc , x0 ,xdata,ydata,LB,UB,optimset);
THIS CODE WAS TESTED IN MATLAB 2020...
function ebolab(do_estimation,xdata,ydata)
P_Data( : ,1) = 1:19; %S i e r r a Leone
P_Data (:,2)=[158 525 907 1813 3706 6599 9004 10340 11301 11841 12362 12701 13093 13264 13541 13846 14052 14122 14122 ]/700; % SierraLeone
Lambda = 60000; % Sierra Leone
p = 0.8;
rho= 0.62;
mu =0.012;
eta =2.1;
beta =0.00000001;
alpha = 0.01;
delta = 0.6;
k =0.0044;
Q1= alpha + mu + delta ;
%S0 =4600000; I0=1 ; D0=0; %L ib e r i a
S0 =7396000; I0= 1 ; D0=0; % S i e r r a Leone
INITIAL=[S0,I0,D0] ;
Istart = 1 ; %month to start the model simulation
Iend= Istart + 19 ; %S i e r r a Leone
%Iend= Istart + 21 ; % Libe ri a
OPTIONS= odeset('AbsTol',0.001,'RelTol',0.001,'MaxStep',1/12);
% %Estimate parameters
%by minimizing the sum of squares
%when f i t t i n g modeled to r e a l prevalence data
do_estimation=1;
if(do_estimation)
x0 ( 1 , 1)= 30000;
x0 ( 1 , 2 ) = 0.8 ;
x0 ( 1 , 3)= 0.62 ;
x0 ( 1 , 4 ) = 0.012 ;
x0 ( 1 , 5 ) = 2.1 ;
x0 ( 1 , 6)= 0.0000001;
x0 ( 1 , 7)= 0.01 ;
x0( 1 , 8)= 0.0044 ;
x0 ( 1 , 9)= 0.6 ;
% Parameters range , LB = upper bound , LB = lower bound
LB=[0.1001 0.1 0.6 0.010 2 0.0000001 0.0100 0.001 0.5] ;% both
UB=[ 60000 0.9 0.9 0.8 5 0.000005 0.9 0.5 0.9 ] ; % S i e r r a Leone
x=lsqcurvefit( @Model_Inc , x0 ,xdata,ydata,LB,UB,optimset);
%'estimated parameters'
Lambda=x(1);
p=x ( 2 );
rho =x ( 3 );
mu =x ( 4 ) ;
eta =x ( 5 );
beta=x ( 6 );
alpha=x ( 7 );
k=x ( 8 );
delta=x ( 9 );
end
[t,y]= ode45( @ebola,0 : 1 / 12 : ( Iend-Istart ), INITIAL ) ;
S=y(:,1);
I=y( : , 2 ) ;
D=y( : , 3 ) ;
incidence = y( : , 2 ) ;
close all ;
figure (1) ;
hold on
h_l=plot( Istart+t , y ( : , 2 ) , ' r-');
set ( h_l , 'linewidth ' , 2 ) ;
h_l=plot ( P_Data (:,1) , P_Data ( : , 2 ) , ' bo' , 'Markersize',8) ;
set ( h_l , 'linewidth',2) ;
box off
axis ( [ Istart Iend 0 10 ] ) ;
xticks ( [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]); % S i e r r a Leone
xticklabels ( { 'Jun_{ 2 0 1 4 }', 'Jul ' , 'Aug' , 'Sept ' 'Oct ' , 'Nov' , 'Dec ' , 'Jan_ { 2 0 1 5 } ' , 'Feb ' , 'Mar ' ,'Apr ' , 'May' , 'Jun ' , 'Jul ' , 'aug ' ,'Sept ' , 'Oct ' , 'Nov' , 'Dec ' } )
xlabel ( 'Months ' , 'font size ' , 12 )
ylabel ( 'Cumulative number of Ebola cases ' , 'fontsize ' , 12)
xtickangle (-45)
hold off
function [ydot]=ebola(~,y)
S=y(1) ;
I=y(2) ;
D=y (3) ;
ydot(1) =Lambda-( beta *(1-p ) * ( y ( 2 ) + eta *y ( 3 ) ) * exp(-((y( 2)+eta*y ( 3 ) ) * k ))) * y(1)- mu*y ( 1 ) ;
ydot(2) = ( beta *(1-p ) * ( y ( 2 ) + eta*y ( 3 ) ) * exp(-((y( 2)+eta*y ( 3 ) ) * k ) ) ) * y ( 1 ) - Q1*y ( 2 ) ;
ydot( 3 )= delta *y ( 2 ) - rho *y ( 3 ) ;
ydot=ydot';
end % function
function Inc=Model_Inc ( x0 , xdata )
Inc =0; %i n t i a l i z a t i o n of t h i s not to have an empty array
Lambda=x0(1);
p =x0 (2) ;
rho=x0 (3) ;
mu =x0 (4) ;
eta =x0 (5) ;
beta=x0 (6) ;
alpha=x0 (7) ;
k=x0 (8) ;
delta=x0 (9) ;
%S0 =4600000; I0 =1; D0=0; %Lib e ri a
S0 =7396000; I0= 1 ; D0=0; % S i e r r a Leone
INITIAL=[S0,I0,D0] ;
OPTIONS= odeset('AbsTol',0.001,'RelTol',0.001,'MaxStep',1/12);
t=50;
[ t,y] = ode45 ( @ebola , [0 : 1 / 1 2 : Iend-Istart ], INITIAL ) ;
S=y( : ,1) ;
I=y ( : ,2) ;
D=y ( : ,3) ;
incidence=y( : ,2) ;
for j=1:length ( xdata )
ind=find ( xdata(j)-Istart==t);
S=y ( ind ,1) ;
I=y ( ind ,2) ;
D=y ( ind ,3) ;
incidence(j)=I;
end
end % end of Model_prev
end
  2 comentarios
per isakson
per isakson el 24 de Mayo de 2020
The function
function Inc=Model_Inc ( x0 , xdata )
returns zero regardless of input.
Provide values for
do_estimation, xdata, ydata
so we can try to run your code,
Cumpaniciu Alexandru
Cumpaniciu Alexandru el 24 de Mayo de 2020
Thanks!

Iniciar sesión para comentar.

Respuestas (1)

Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato el 24 de Mayo de 2020
Editada: Thiago Henrique Gomes Lobato el 24 de Mayo de 2020
Your Model_Inc function is not correct written, since it always return zero for a dummy variable you created in the beggining. I believe what you actually wanted to do was:
function incidence=Model_Inc ( x0 , xdata )
Besides this you need to provide inputs for xdata and ydata, you also don't run those functions directly in editor, but rather call them, as in:
xdata = % your xdata
ydata = % your ydata
do_estimation = % your do_estimation
ebolab(do_estimation,xdata,ydata)
  4 comentarios
Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato el 24 de Mayo de 2020
Editada: Thiago Henrique Gomes Lobato el 24 de Mayo de 2020
You're right, for some reason I thought he was doing the function handle twice. I will edit my answer.
Cumpaniciu Alexandru
Cumpaniciu Alexandru el 24 de Mayo de 2020
THANKS!

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by