Getting an error of "Not enough input arguments."

조회 수: 2 (최근 30일)
Sumukh Desu
Sumukh Desu 2015년 6월 5일
댓글: Walter Roberson 2015년 6월 8일
I'm defining a function which returns a vector used for design of fir filters using hamming window. I am not able to see where I'm going wrong and would appreciate if someone could help me out
Function:
function a = firfilt2(wp,ws)
n=ceil(8/(ws-wp));
if(rem(n,2)==0)
n=n+1;
end
y=hamming_alg(n);
a=fir1(n-1,wp,y);
end
function hm_wind = hamming_alg(n)
hm_wind=zeros(1,n);
for i=1:n
hm_wind(i) = 0.54 - 0.46*cos((2*pi*i)/(n-1));
end
end
Testcase:
rp=0.25;
rs=50;
wp=0.3;
ws=0.45;
filt=firfilt2(wp,ws);
freqz(filt,1);
Error Message :
>>firfilt2
Error using firfilt2 (line 2)
Not enough input arguments.
I've also tried another program which does the same thing and also determines the window automatically by using Stop Band Gain. That seemed to show the same error message. I've tried most of the tips online and also tried to debug the code line by line.

답변 (2개)

dpb
dpb 2015년 6월 5일
Your sample line invokes your function firfilt2 with no arguments. Not sure why you did that...otherwise, looks like the sample test should run from the command line.
  댓글 수: 5
Sumukh Desu
Sumukh Desu 2015년 6월 8일
I'm really sorry. Like you mentioned it's line 2 which is giving the error. In the original code there was a space which meant there was nothing written at line 2. I will try the suggestions and debug the code. Thanks a lot.
Walter Roberson
Walter Roberson 2015년 6월 8일
Line 2 was the first line on which you attempted to use one of the input arguments that you did not supply when you invoked the code.

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


Jan
Jan 2015년 6월 6일
편집: Jan 2015년 6월 6일
Use
dbstop if error
to find out, which line causes the troubles. Which line is "line 3"?
Be sure, that the file has been saved before calling and do not use the RUN-menu in the editor, because it does not define the inputs.
  댓글 수: 1
Sumukh Desu
Sumukh Desu 2015년 6월 8일
I'm really sorry. Like you mentioned it's line 2 which is giving the error. In the original code there was a space which meant there was nothing written at line 2. I will try the suggestions and debug the code and get back to you. Thanks a lot.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by