MATLAB Answers

can anyone help to solve this matlab error of not enough input arguments?

4 views (last 30 days)
Pooja Prajapati
Pooja Prajapati on 26 Jan 2017
Commented: Walter Roberson on 28 Jan 2017
function [ceps,freqresp,fb,fbrecon,freqrecon]=mfcc(input,fs,frate)
global mfccDCTMatrix mfccFilterWeights
[r,c]=size(input); % error occur in this line
if(r > c)
input=input';
end

Accepted Answer

Niels
Niels on 27 Jan 2017
Edited: Niels on 27 Jan 2017
so...
you changed the order of the input arguments again?... you have to decide yourself wether it shall be
1. case
function [ceps,freqresp,fb,fbrecon,freqrecon]=mfcc(w1,fs,frate)
or 2. case
function [ceps,freqresp,fb,fbrecon,freqrecon]=mfcc(fs,w1,frate)
to call your function type in your command window
1. case
[ceps,freqresp,fb,fbrecon,freqrecon]=mfcc(w1,fs,frate)
ofc you have the set the variables w1, fs and frate to some values... thats what walter did: also in the command window
w1=rand(50, 864);
fs=9600, 57.2);
frate=57.2;
% then call your function like shown above or
2. case
[ceps,freqresp,fb,fbrecon,freqrecon]=mfcc(fs,w1,frate)
in your picture you put a single number as input for w1, i thought you might expect w1 to be a matrix (since you check its size etc), walter generated a random matrix with size 50x864
  3 Comments

Sign in to comment.

More Answers (2)

Guillaume
Guillaume on 26 Jan 2017
Clearly, you've called the function without giving it any input. I.e, you should call the function with:
mfcc(somevariable, someothervariable, somethingelse)
Note that calling the first input input is a very bad idea as it overrides the matlab function with the same name. Give that first input a different name.
Also, I would strongly reconsider having global variables. Whatever time saving it may give you now, you'll likely spend twice as much debugging weird issues later on.
  7 Comments
Walter Roberson
Walter Roberson on 28 Jan 2017
w1 should be the data to be processed.
fs should be the sampling frequency the data was processed for.
frate should be the number of windows that the data will be broken up into. If you do not provide a value then 100 will be used by default.

Sign in to comment.


Pooja Prajapati
Pooja Prajapati on 27 Jan 2017
Edited: Walter Roberson on 27 Jan 2017
@niels ya i knew that,
u r ri8 bt it's not running so i tried it with changing the order of inputarguments.
but u can see my full code,
nw please help in out of this error,
my code is,
function [ceps,freqresp,fb,fbrecon,freqrecon]=mfcc(w1,fs,frate)
global mfccDCTMatrix mfccFilterWeights
[r,c]=size(w1);
if(r > c)
w1=w1';
end
lowestFrequency=133.3333;
linearFilters=13;
linearSpacing=66.66666666;
logFilters=27;
logSpacing=1.0711703;
fftSize=256;
cepstralcoefficients=13;
windowSize=256;
if(nargin < 2)
fs=11025;
end
if(nargin < 3)
frate=100;
end
totalFilters=linearFilters+logFilters;
freqs=lowestFrequency+(0:linearFilters-1)*linearSpacing;
freqs(linearFilters+1:totalFilters+2)=freqs(linearFilters)*...
logSpacing .^ (1:logFilters+2);
lower=freqs(1:totalFilters);
center=freqs(2:totalFilters+1);
upper=freqs(3:totalFilters+2);
mfccFilterWeights=zeros(totalFilters,fftSize);
triangleHeight=2 ./ (upper-lower);
fftFreqs=(0:fftSize-1)/fftSize*fs;
for i=1:totalFilters
mfccFilterWeights(i,:)=(fftFreqs>lower(i) & ...
fftFreqs<= center(i)).* triangleHeight(i).*...
(fftFreqs-lower(i))/(center(i)-lower(i))+...
(fftFreqs>center(i) & fftFreqs<upper(i)).* ...
triangleHeight(i).*(upper(i)-fftFreqs)/(upper(i)-center(i));
end
hamWindow=0.54-0.46*cos(2*pi*(0:windowSize-1)/windowSize);
if 0
windowSize=fs/frate;
a=0.54;
b=-0.46;
wr=sqrt(windowStep/windowSize);
phi=pi/windowSize;
hamWindow=2*wr/sqrt(4*a*a+2*b*b)*...
(a+b*cos(2*pi*(0:windowSize-1)/windowSize+phi));
end
mfccDCTMatrix=1/sqrt(totalFilters/2)*...
cos((0:(cepstralcoefficients-1))'* ...
(2*(0:(totalFilters-1))+1)*pi/2/totalFilters);
mfccDCTMatrix(1,:)=mfccDCTMatrix(1,:)*sqrt(2)/2;
if 1
preEmphasized=filter([1-0.97],1,w1);
else
preEmphasized=w1;
end
windowStep=fs/frate;
cols=fix((length(w1)-windowSize)/windowStep);
if(nargout>4)
fr=(0:(fftSize/2-1))'/(fftSize/2)*fs/2;
j=1;
for i=1:(fftSize/2)
if fr(i) > center(j+1)
j=j+1;
end
if j > totalFilters-1
j=totalFilters-1;
end
fr(i)=min(totalFilters-0.0001, ...
max(i,j+(fr(i)-center(j))/(center(j+1)-center(j))));
end
fri=fix(fr);
frac=fr-fri;
freqrecon=zeros(fftSize/2,cols);
end
for i=0:cols-1
first=i*windowStep+1;
last=first+windowSize-1;
fftData=zeros(1,fftSize);
first=fix(first);
last=fix(last);
fftData(1:windowSize)=preEmphasized(first:last).*hamWindow;
fftMag=abs(fft(fftData));
earMag=log10(mfccFilterWeights*fftMag');
ceps(:,i+1)=mfccDCTMatrix*earMag;
if(nargout > 1)
freqresp(:,i+1)=fftMag(1:fftSize/2)';
end
if(nargout > 2)
fb(:,i+1)=earMag;
end
if(nargout > 3)
fbrecon(:,i+1)=mfccDCTMatrix(1:cepstralcoefficients,:)'* ...
ceps(:,i+1);
end
if(nargout > 4)
f10=10.^fbrecon(:,i+1);
freqrecon(:,i+1)=fs/fftSize* ...
(f10(fri).*(1-frac)+f10(fri+1).*frac);
end
end
if 1 && (nargout > 3)
fbrecon=mfccDCTMatrix(1:cepstralcoefficients,:)'*ceps;
end
end
  4 Comments
Pooja Prajapati
Pooja Prajapati on 27 Jan 2017
ok wait niels wait,
walter's code works nw,
But now what to do,
I have no idea about w1,
i changes the value for fs & frate for w1 i just put walter's random no 9600 for w1 & it works.
so can you please tell me about w1.
And now what command i have to give for run it,
fond the screenshot of it from attchmnets

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!