% Create 32 mel-scale filterbanks, for use on a 512-point FFT W=melbankm(32,512,8000); % Cut WAV into 160-sample windows, overlapping by 120 samples FRAMES=enframe(WAV,160,40); % Compute magnitude STFT MSTFT=abs(fft(FRAMES,512,2)); % Multiply MSTFT times W to create mel-scale spectrogram MELGRAM=20*log10(W*MSTFT(:,1:257)'); % Compute center frequencies, in Hertz, of each filter FREQS=round(mel2frq([1:32]*frq2mel(4000)/33)); % Compute time alignments, in milliseconds, of each frame TIMES=[-140:5:140]; % Create an image plot of the mel-scale spectrogram imagesc(TIMES,FREQS,MELGRAM); % Flip the frequency axis, so low frequency is at bottom axis xy; %% Alternate code -- necessary only if your version of matlab has %% the bug that causes nonlinear Y-axis to fail imagesc(TIMES,[1:32],MELGRAM); axis xy; YTick=get(gca,'YTick'); YTickLabel=''; for I=YTick, YTickLabel=strvcat(YTickLabel,sprintf('%d',FREQS(I))); end set(gca,'YTickLabel',YTickLabel);