Can any one please tell me how I can remove this error in MFCC?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Gaurav Sharma
el 29 de Nov. de 2018
Comentada: Gaurav Sharma
el 29 de Nov. de 2018
Hi there,
I am trying to run the code but not getting the correct plot with the melfilter. And that's why I tried oopp.m to get the curve. But the outout of that oopp.m is 1x12 while that of FFTFreqMat is of 1x501. what should I need to do? Because I want this step for my further code to run.
%============================================================================================
oopp.m
%function [f] = oopp(f2)
f=zeros(1,501);
f1=0;f2=12500;
n=10;
fm1=2595*log10(1+f1/700);
fm2=2595*log10(1+f2/700);
fmw=(fm2-fm1)/(n+1);
fm=fm1:fmw:fm2;
f=700*(exp(fm/1125)-1)
%=========================================================
MFCCProcessor.m
N = 256;
M = 100;
Frames = 1 + floor((length(y) - N)/double(M));
V = zeros(N, Frames);
for n=1:Frames
k = 100*(n-1) + 1;
for j=1:N
V(j,n) = y(k);
k = k + 1;
end
end
W = hamming(N);
WresultMatrix = diag(W)*V;
FreqFFTMatrix = fft(WresultMatrix);
[MelFrequencyVector] = oopp(Fs);
y2 = 1 + floor(N/2);
ms = MelFrequencyVector*abs(FreqFFTMatrix(1:y2)).^2;
%=============================================================
at this point it throws error=>
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise
multiplication, use '.*'.
Error in MFCCProcessor (line 66)
ms = MelFrequencyVector*abs(FreqFFTMatrix(1:y2)).^2;
Error in phase1 (line 19)
MFCC = MFCCProcessor(y,Fs,i+2);
4 comentarios
Walter Roberson
el 29 de Nov. de 2018
That would generate an error about an attempt to call script MFCCProcessor as a function.
Respuesta aceptada
Walter Roberson
el 29 de Nov. de 2018
N = 256;
[..]
y2 = 1 + floor(N/2);
so y2 will be 1+floor(256/2) which will be 129.
ms = MelFrequencyVector*abs(FreqFFTMatrix(1:y2)).^2;
the first 129 entries from FreqFFTMatrix will be used. When we look at
W = hamming(N);
WresultMatrix = diag(W)*V;
we can see that diag(W) will be a 2D array not a vector, and 2D array * anything has a result that has multiple rows. When we then do
FreqFFTMatrix = fft(WresultMatrix);
we know the output is the same size as the input, so FreqFFTMatrix will have multiple rows. Therefore indexing entries 1:y2 of it will have multiple rows -- a column vector result. (If FreqFFTMatrix had been a row vector then indexing 1:y2 would have given a row vector result.)
Then, abs() of a column vector gives a column vector, and squaring that stays a column vector. Thus the right hand side of
ms = MelFrequencyVector*abs(FreqFFTMatrix(1:y2)).^2;
will have multiple rows and 1 column. In particular it will have y2 = 129 rows. For the * operation to succeed, MelFrequencyVector would have to have the same number of columns that the abs().^2 has rows, so MelFrequencyVector would have to have 129 columns. If the name of the variable is accurate, it would have to be a row vector with 129 columns.
... But is it?
[MelFrequencyVector] = oopp(Fs);
So we look at oopp
%function [f] = oopp(f2)
Well, that is a problem. No function line. You are attempting to access script oopp as if it were a function.
If we say "Oh that's a typo, the % is not really there", then we can proceed,
f1=0;f2=12500;
Look at us ignoring the input value.
With that fixed value of f2, the number of entries returned in the vector is 12.
We can then proceed to try to trace through with a different upper bound f2 expecting that it might give a different number of outputs. However except for degenerate cases like f2 = 0, then it turns out that the logic in that code will return a vector of length n+2 where n=10 is set in the code. n would have to be set to 127 in oopp in order to return a row vector of length 129 to match the 129 entries of y2 so that ms would get down to a scalar.
3 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Multichannel Audio Input and Output en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!