Why does spectrogram's result Matrix not have the length of the window

I am learning about audio processing techniques and have been using a spectrogram to do analysis. Now, I would have thought that the result of the spectrogram would be an M x N matrix, where M would be the window length, and N the number of windows. However the spectrogram function returns a matrix of a different length than I would expect:
data = [...]; % the data, a 1 x 9171 array
wdw = 160; % window size
overlap = 80; % window overlap
numWindows = floor(length(data)/(wdw - overlap)) - 1; % returns 113 as expected
nfft = 256; % fft size
Fs = 16000; % sample freq
s = spectrogram(data,hamming(wdw),overlap,nfft,Fs);
s returns as a 129 x 113 matrix, whereas I would expect a 160 x 113 matrix. Does anyone know why the function truncates the length of each window?

Risposte (1)

Kunz
Kunz il 29 Dic 2017
Modificato: Kunz il 29 Dic 2017
If you write
s = spectrogram(data,hamming(wdw),overlap,wdw,Fs);
in the last line, then the row size in s would be 160. Matlab picks max(256, window_size) as the size of the nfft.
The default return format is one-sided spectrogram using 256 nfft coefficients. Half of 256 plus a zero frequency gives you 129 entries along the row axis. For more information, see the Matlab documentation on the nfft argument in the spectrogram function ( https://de.mathworks.com/help/signal/ref/spectrogram.html ).

Richiesto:

il 3 Set 2016

Commentato:

Jan
il 29 Dic 2017

Community Treasure Hunt

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

Start Hunting!

Translated by