Not enough input arguments error

Hello Guys, could anyone help me with this error? I have this code:
function [error,variance_theoritical,variance_practical,SQNR_theoritical,SQNR_practical]= quantizer(L)
x=2*9*rand(1,10000) -9;
maximum=max(x);
minimum=min(x);
delta=(maximum-minimum)/L;
range=maximum: delta: minimum;
qc=1;
error=0;
vc=1;
for k=1:1:length(range)-1;
averageOFrange=(range(k)+range(k+1))/2
k=k+1
end
avg=averageOFrange;
for i=1:1:length(x)
z=x(i);
for j=1:1:L-1
if z>=avg(j)
Level=range(j+1);
break
elseif z<avg(j)
Level=range(j);
break
Q(qc)=Level;
qc=qc+1;
end
error=error+abs(z-Q(qc));
VP(vc)= z-Q(qc);
vc=vc+1;
end
variance_theoritical=delta*delta/12;
SQNR_theoritical=9*9/variance_theoritical;
end
variance_practical=var(VP);
SQNR_practical=9*9/variance_practical;
and when I run it, this error comes out:
Error using quantizer (line 6) Not enough input arguments.
Any help? Thanks a lot in advance

1 件のコメント

Daniel Shub
Daniel Shub 2012 年 11 月 16 日
Please post the entire error message and the command you type that gives the error.

サインインしてコメントする。

回答 (1 件)

Daniel Shub
Daniel Shub 2012 年 11 月 16 日

0 投票

The error is not in quantizer function, but rather in how you are calling it. In line 6 of whatever function you are calling is something like
x = quantizer;
without any inputs to quantizer.

6 件のコメント

LOLO93
LOLO93 2012 年 11 月 16 日
It points at the line: delta=(maximum-minimum)/L; I don't know what is the problem in here, I'm not calling quantizer or anything :/
Thomas
Thomas 2012 年 11 月 16 日
編集済み: Thomas 2012 年 11 月 16 日
As Daniel pointed out, you cannot run a function that requires inputs, in this case L with out specifying it. Its giving. you an error in line 6 because it cannot find L
try calling the function like
quantizer(20) % where L=20
LOLO93
LOLO93 2012 年 11 月 16 日
Oh I see, thanks a lot Thomas and Daniel, I really appreciate it :D
LOLO93
LOLO93 2012 年 11 月 16 日
But I still don't know how to use the input if it will keep on giving me this error, I don't want to use a fixed number, it should be input by the user, you know? :/
Walter Roberson
Walter Roberson 2012 年 11 月 16 日
Then have another routine that prompts the user for the number and then calls your quantizer routine.
LOLO93
LOLO93 2012 年 11 月 16 日
How can I do this Walter? I've made another m-file called main quantizer and I put the level number as 2, but still, the error is persistent :(

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeData Type Identification についてさらに検索

質問済み:

2012 年 11 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by