Zero padding in spectrogram function

32 views (last 30 days)
yossef cohen
yossef cohen on 10 Aug 2019
Answered: Galdir Reges on 31 Jul 2020
Hi, i am kinda new with matlab. how do i use zeropadding to test if i get better results?
after i load the data of my experiments i use the following code:
window = 512 ;
figure(2);
spectrogram(data,blackman(window),500,window, fs ,'yaxis');
xlabel('Time (sec)');
ylabel('Frequency (Hz)');
colormap jet ;
thanks for help!
  1 Comment
dpb
dpb on 10 Aug 2019
Paste 'em on the end of your input vector

Sign in to comment.

Answers (1)

Galdir Reges
Galdir Reges on 31 Jul 2020
If you want zero padding to increase the resolution of each short time fft, you must change the nfft in syntax
spectrogram(x,window,noverlap,nfft, fs)
If X is a vector and the length of X is less than nfft, then X is padded with trailing zeros to length nfft.(https://www.mathworks.com/help/matlab/ref/fft.html)
Also, you define can use the syntax with cyclical frequencies, specified as a vector. f must have at least two elements, because otherwise the function interprets it as nfft. The units of f are specified by the sample rate, fs.
spectrogram(x,window,noverlap,f, fs)
then f specify a frequency zoom and zero padding. For example, f=[55:0.001:65], with fs in samples per second, set the spectrogram to the range between 55Hz and 65Hz also with a frequency increment of 0.001 Hz using enough zero padding to that

Categories

Find more on Time-Frequency Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by