Too many input arguments.

조회 수: 5 (최근 30일)
Otthman Otth
Otthman Otth 2022년 6월 28일
편집: dpb 2022년 7월 2일
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
Steven Lord
Steven Lord 2022년 6월 28일
You haven't showed us the definition of the CemaNeige function, but apparently from the error message it is not defined to accept 13 input arguments. It is defined to accept fewer than 13 inputs.
You're passing into CemaNeige the inputs you unpacked from the userdata input of objCemaNeigesce in a different order than they're arranged in userdata. To me that smells like it will cause a problem for users of objCemaNeigesce and/or CemaNeige at some point, where they'll pass the inputs into objCemaNeigesce in the order that CemaNeige expects or vice versa. At the very least one or both functions should have help text clearly indicating their calling signature.
Otthman Otth
Otthman Otth 2022년 6월 28일
편집: dpb 2022년 6월 28일
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

댓글을 달려면 로그인하십시오.

채택된 답변

dpb
dpb 2022년 6월 29일
편집: dpb 2022년 7월 2일
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...

추가 답변 (1개)

Otthman Otth
Otthman Otth 2022년 7월 2일
Hi
Thank you

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by