MATLAB Answers

Angelina
0

How to solve the error : Error "not enough input arguments"

Asked by Angelina
on 17 Oct 2015
Latest activity Commented on by Jan
on 17 Oct 2015
Hi all, Can anyone help me to resolve my problem. I'm a beginner in matlab.
There are my codes (porn2 and Calcn2)
%
porn2 code
clear all
enf=input('NOM DU FICHIER : ','s');
path(path,'C:\Users\razafiti5\Documents\MATLAB')
nfi=[enf,'.iso'];
eval(['load ',nfi])
eval(['ppo=',enf,'(:,1);'])
eval(['v=',enf,'(:,2);'])
plot(ppo,v)
i0=1;
l=length(v);
for i=2:l
if ppo(i)>ppo(i0)
i0=i;
end
end
ppod=ppo(i0:l);
vd=v(i0:l);
plot(ppo,v,ppod,vd)
va=v(1:i0);
ppoa=ppo(1:i0);
ld=length(ppod);
if vd(ld)>.1
vref=interp1(ppoa,va,ppod(ld));
j=find(ppoa>.04 & ppoa<ppod(ld))
ppod=[ppod
ppoa(j)];
vd=[vd
va(j)+vd(ld)-vref];
end
plot(ppoa,va,ppod,vd)
x=.1:.01:.98;
%x=[x .901:.001:.98];
vxd=interp1(ppod,vd,x);
vxa=interp1(ppoa,va,x);
plot(ppoa,va,ppod,vd,x,vxd,x,vxa)
pause
vx=vxa;
ai=input('ads (0) ou des (1)');
if ai==1
vx=vxd;
end
Calcn2
%Calcn2 code
Pt=[0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 .62 .64 .66 .68 .7 .72 .74 .76 .78 .8 .82 .84 .86 .88 .9 .91 .92 .93 .94 .95 .96 .97 .98];
ta=[3.674 3.819 3.94 4.1 4.23 4.36 4.49 4.62 4.75 4.88 5.01 5.14 5.27 5.41 5.56 5.71 5.86 6.02 6.18 6.34 6.5 6.66 6.8 6.99 7.17 7.36 7.56 7.77 8.02 8.26 8.57 8.91 9.27 9.65 10.07 10.57 11.17 11.89 12.75 13.82];
ta=[ta 14.94 15.55 16.2 16.87 17.58 18.32 19.09 19.91 20.78];
tx=interp1(Pt',ta',x);
rkel=-9.5604./log(x);
vxliq=vx*15.47;
dvl=diff(vxliq);
dtx=diff(tx);
ll=length(tx);
smacro=input('surface macro = ');
while smacro>-1
surfp(ll)=smacro;
surfc(ll)=smacro;
volp(ll)=0;
volc(ll)=0;
for i=length(tx)-1:-1:1;
volp(i)=dvl(i)-surfp(i+1)*dtx(i);
volc(i)=dvl(i)-surfc(i+1)*dtx(i);
surfp(i)=surfp(i+1)+volp(i)/(rkel(i)+2*tx(i))*2/rkel(i).*(rkel(i)+2*tx(i)');
surfc(i)=surfc(i+1)+volc(i)./(rkel(i).^2).*((rkel(i)+tx(i)').^2)/(rkel(i)+tx(i))*2;
end
vcorp=volp./rkel.*(rkel+2.*tx);
vcorc=volc./(rkel.^2).*((rkel+tx).^2);
rcorp=rkel+2*tx;
rcorc=rkel+tx;
vcump(1)=vcorp(1);
vcumc(1)=vcorc(1);
for i=2:length(vcorp)
vcump(i)=vcump(i-1)+vcorp(i);
vcumc(i)=vcumc(i-1)+vcorc(i);
end
porpar=vcump(length(vcorp))/15.47*1.547e-3
porcyl=vcumc(length(vcorp))/15.47*1.547e-3
rxp=10:1:400;
vcxp=interp1(rcorp,vcump,rxp);
vcxc=interp1(rcorc,vcumc,rxp);
plot(rcorp,vcump,rxp,vcxp,rcorc,vcumc,rxp,vcxc)
pause
[xdistp,ydistp]=dtg1(rxp,vcxp);
[xdistc,ydistc]=dtg2(rxp,vcxc);
plot(xdistp,ydistp,2*xdistc,ydistc/2)
grid
smacro=input('surface macro = ');
end
mat1=[x rcorc vcorc vcumc surfc rcorp vcorp vcump surfp];
mat2=[2.*xdistc ydistc./2 xdistp ydistp];
if ai==1
fich1=['save a:',enf,'.n2d mat1 /ascii'];
eval(fich1)
else
fich1=['save a:',enf,'.n2a mat1 /ascii'];
eval(fich1)
end
if ai==1
fich1=['save a:',enf,'.des mat2 /ascii'];
eval(fich1)
else
fich1=['save a:',enf,'.ads mat2 /ascii'];
eval(fich1)
end
This is the error message :
Undefined function 'dtg1' for input arguments of type 'double'.
Error in Calcn2 (line 43)
[xdistp,ydistp]=dtg1(rxp,vcxp);
Error in porn2 (line 52)
Calcn2
No idea of how to solve this problem.
Thank you to everybody answers!

  2 Comments

Angelina - your question title refers to one error message (not enough input arguments) and your question body refers to another (undefined function). Which line of code does the first error message correspond to? Typically it means that you are not supplying enough input arguments into the function that you are calling. As for the second error, what are the functions dtg1 and dtg2? Have you written these two functions and/or are they within the MATLAB search path? In the Command Window type
which -all dtg1
to locate this function. See which for more details.
Avoid eval :
eval(['load ',nfi])
What about:
load(nfi)
?? As discussed in this forum frequently, eval makes your live so much harder without benefits. It's worth to start a search in the forum.

Sign in to comment.

0 Answers