can anyone help to solve this matlab error of not enough input arguments?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Niels
2017년 1월 27일
편집: Niels
2017년 1월 27일
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
Niels
2017년 1월 27일
편집: Niels
2017년 1월 27일
The values in my/ walters answer are just random numbers.
You shouldnt use these results getting from our example for anything. You need to Fill the variables with your own data. You might have some. Otherwise why would you try to use this function.
To answer your questions: i propose you do as guillaume said. Learn the basics. That will improve your understanding of how functions work. And i am sry but i cant help you any further because i have no clue of working with audio files.
추가 답변 (2개)
Guillaume
2017년 1월 26일
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
Guillaume
2017년 1월 27일
편집: Guillaume
2017년 1월 27일
As Walter and I told you, you need to call the function with the required number of inputs. The same way that if you call
y = sin()
matlab returns the error not enough input arguments since you need at least one input for sin.
What that input should be, only you knows, the same way only you knows what angle you want the sin of.
If it's a function you wrote, I don't understand how you don't know what the inputs should be. They're whatever you thought was necessary. If it's not a function you wrote then refer to its documentation or ask its author. We can't guess that for you. The only thing that is clear from your code sample is that this badly named input should be a 2D matrix.
It looks to me that you're lacking some very basic understanding of how matlab works. I would recommend you go through the getting started tutorial and learn about functions
Walter Roberson
2017년 1월 28일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!