getting error "??? Subscripted assignment dimension mismatch." in assignment

1 view (last 30 days)
i am creating a speech recognition of digits.i got a demo code in which i found an error that stucked me there from many days.i did not able to resolve it out.so plz help me if anyone can solve this and tell me what is the problem ,that error is occurring.
this is code:
function mfccs = mfcc(word, fs);
nfft = 512;
window = hamming(512);
Noverlap = nfft/2;
[B,f] = specgram(word,nfft,fs,window,Noverlap);
magB = abs(B);
magB = magB.^4;
%calculate convert frequency vector to bark scale
z = 13*atan(.00076*f) + 3.5*atan((f./7500).^2);
% [mfccs,fr,fb]=mfcc2(word,8000);
z = floor(z);
%cutoff bins above 3.7kHz
z = z(z<17);
%adjust magB based on length of z
magB = magB(1:length(z),:);
for bark = 0:16
eArray(bark+1,:) = sum(magB(find(z==bark),:)); %error is here************************************************
end
% assume that energies in each bark band is similar to mel-filterbank
% outputs in each bark band
%Take log of output filterbank energies
logArray = log10(eArray);
[N,M] = size(logArray);
for frame= 1:M
mfccs(:,frame) = dct(logArray(:,frame));
end
%take only 1st 12 coefficients
mfccs = mfccs(1:12,:);
  5 Comments
Jan
Jan on 2 Aug 2015
@Walter: Thanks. Never check a thread on a smartphone assuming scrolling to the right will reveal important details.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 2 Aug 2015
magB(find(z==bark),:) can be optimized as magB(z==bark,:) but that is a side note.
If there are multiple matching z, then you are extracting a 2 dimensional array. sub() applied on that 2 dimensional array would (by default) result in a row vector, summing down the columns. You would then try to store that row vector into a single location.

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!