Too many input arguments.

4 views (last 30 days)
Otthman Otth
Otthman Otth on 28 Jun 2022
Edited: dpb on 2 Jul 2022
Hi everyone, I have this fucntion and I get error during the running
function f = objCemaNeigesce(x,userdata)
Pt = userdata( :,1 ) ;
Tmoy = userdata( :,2 ) ;
Tmin = userdata( :,3 ) ;
Tmax = userdata( :,4 ) ;
lame_deau = userdata( :,5 ) ;
Zz = x.Zz ;
ZmedBV = x.ZmedBV ;
Beta = x.ZmedBV ;
gradT = x.gradT ;
Tf = x.Tf ;
Vmin = x.Vmin ;
QNBV = x.QNBV ;
[lame_deau,perf] = CemaNeige( Pt, lame_deau, Tmoy, Tmax, Tmin, Zz, ZmedBV, Beta, gradT, Tf, QNBV, Vmin);
f = perf(1) ;
Here is error I get :
>> objCemaNeigesce(x,userdata)
Error using CemaNeige
Too many input arguments.
Error in objCemaNeigesce (line 25)
[lame_deau,perf] = CemaNeige( Pt, lame_deau, x,
Tmoy, Tmax, Tmin, Zz, ZmedBV, Beta, gradT, Tf,
QNBV, Vmin);
Someone can help me?
Thank
  2 Comments
Otthman Otth
Otthman Otth on 28 Jun 2022
Here is CemaNeige function
function [lame_eau, CemaParam] = CemaNeige( Pt, Tmoy, Tmax, Tmin, Date, CemaParam )
G = CemaParam.G;
eTg = CemaParam.eTg;
Zz = CemaParam.Zz;
ZmedBV = CemaParam.ZmedBV;
Beta = CemaParam.Beta;
gradT = CemaParam.gradT;
Tf = CemaParam.Tf;
QNBV = CemaParam.QNBV;
Vmin = CemaParam.Vmin;
CTg = CemaParam.CTg;
Kf = CemaParam.Kf;
[JJ] = JJdate (Date(1),Date(2),Date(3));
eday = zeros( 1,3 ) ;
eday(1) = JJ(1);
eday(2) = Date(1);
eday(3) = eomday(eday(2),2);
if eday(3) == 29
if JJ(1) > 59
JJ(1)=JJ(1)-1;
end
end
i = 1;
ind = JJ(1);
theta = gradT(i);
Tz = Tmoy + theta*(Zz - ZmedBV)./100;
Tzmax = Tmax+theta*(Zz-ZmedBV)./100;
Tzmin = Tmin+theta*(Zz-ZmedBV)./100;
Pdis = Pt/5; % distribution des précipitations sur les 5 zones
modc = exp(Beta*(Zz-ZmedBV));
c = sum(modc)/5;
Pz = (1/c)*Pdis(1)*exp(Beta*(Zz-ZmedBV));
Fracneige = zeros(1,5);
for z = 1 : 5
if ZmedBV < 1500 % Fonction Hydrotel
if Tzmax(z) <= 0
Fracneige(z) = 1;
elseif Tzmin(z) >= 0
Fracneige(z) = 0;
else
Fracneige(z) = 1-(Tzmax(z)/(Tzmax(z)-Tzmin(z)));
end
else % Fonction USGS
if Tz(z) > 3
Fracneige(z) = 0;
elseif Tz(z) < -1
Fracneige(z) = 1;
else
Fracneige(z) = 1-((Tz(z)-(-1))/(3-(-1)));
end
end
end
Fracneige = min(Fracneige,1);
Fracneige = max(Fracneige,0);
Pg = Pz .* Fracneige;
Pl = Pz - Pg;
G = G + Pg;
% Mode journalier: (cas similaire à G)
eTg = CTg*eTg+(1-CTg)*Tz;
% Calcul de l'indice d'état thermique du manteau
eTg = min(0,eTg);
fTg = (eTg >= Tf);
Fpot = (Tz > 0) .* (min(G,Kf*(Tz-Tf).*fTg));
Gseuil = QNBV*0.9;
fnts = min(G/Gseuil,1);
fonte = Fpot .* ((1-Vmin)*fnts+Vmin);
G = G - fonte;
lame_eau = sum(Pl) + sum(fonte);
CemaParam.G = G;
CemaParam.eTg = eTg;
end
function [JJ] = JJdate (A,M,J)
test = and(mod(A,4)==0,or(mod(A,100)~=0,mod(A,400)==0));
x = test+0;
JJ = floor(275*M/9)-(2-x).*floor((M+9)/12)+J-30;
end
function CemaParam = CemaNeigeInit( Zz, ZmedBV, Beta, gradT, x, Tf, QNBV, Vmin )
CemaParam.CTg = x(end-1);
CemaParam.Kf = x(end);
CemaParam.G = zeros( 1,5 ) ;
CemaParam.eTg = zeros( 1,5 ) ;
CemaParam.Zz = Zz;
CemaParam.ZmedBV = ZmedBV;
CemaParam.Beta = Beta;
CemaParam.gradT = gradT;
CemaParam.Tf = Tf;
CemaParam.QNBV = QNBV;
CemaParam.Vmin = Vmin;
end

Sign in to comment.

Accepted Answer

dpb
dpb on 29 Jun 2022
Edited: dpb on 2 Jul 2022
So much for help, Steven!!! :) Doncha just love folks who don't document a thing...not.
function [lame_eau, CemaParam] = CemaNeige( Pt, Tmoy, Tmax, Tmin, Date, CemaParam )
Shows the function expects and requires precisely six (6) input arguments. No more, no less.
So, fix the calling function to match --
[lame_deau,perf] = CemaNeige(Pt, lame_deau, Tmoy, Tmax, Tmin, Zz, ZmedBV, Beta, gradT, Tf, QNBV, Vmin);
was your calling statement; I count 12 instead of 13 inputs, but either is more than six.
Some of the variables you passed seem to match up; whether the fact the names are the same is good enough to be sure they're actually the right ones is another issue, but there are a number you've put in the list that don't match up at all...

More Answers (1)

Otthman Otth
Otthman Otth on 2 Jul 2022
Hi
Thank you

Community Treasure Hunt

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

Start Hunting!