Spectrogram
Spectrogram
Contents
spectrogram
Spectrogram using short-time Fourier transform
Syntax
S=spectrogram(x)
S=spectrogram(x,window)
S=spectrogram(x,window,noverlap)
S=spectrogram(x,window,noverlap,nfft)
S=spectrogram(x,window,noverlap,nfft,fs)
[S,F,T] = spectrogram(...)
[S,F,T]=spectrogram(x,window,noverlap,F)
[S,F,T]=spectrogram(x,window,noverlap,F,fs)
[S,F,T,P]=spectrogram(...)
spectrogram(...,FREQLOCATION)
spectrogram(...)
Description
spectrogram, when used without any outputs, plots a spectrogram or, when
used with an S output, returns the short-time Fourier transform of the input signal.
To create a spectrogram from the returned short-time Fourier transform data, refer
to the [S,F,T,P] syntax described below.
file:///C:/Program%20Files/MATLAB/R2013a/help/signal/ref/spectrogram.html 21/01/2014
spectrogram Página 2 de 6
◾ nfft is the FFT length and is the maximum of 256 or the next power of 2
greater than the length of each segment of x. Instead of nfft, you can specify
a vector of frequencies, F. See below for more information.
k = fix((Nx-noverlap)/(window-noverlap))
or if window is a vector
k = fix((Nx-noverlap)/(length(window)-noverlap))
For real x, the output S has (nfft/2+1) rows if nfft is even, and (nfft+1)/2
rows if nfft is odd.
Note: To obtain the same results for the removed specgram function,
specify a 'Hann' window of length 256.
file:///C:/Program%20Files/MATLAB/R2013a/help/signal/ref/spectrogram.html 21/01/2014
spectrogram Página 3 de 6
S = spectrogram(x,window,noverlap,nfft,fs) uses fs
sampling frequency in Hz. If fs is specified as empty [], it defaults to 1 Hz.
file:///C:/Program%20Files/MATLAB/R2013a/help/signal/ref/spectrogram.html 21/01/2014
spectrogram Página 4 de 6
at all frequencies.
surf(T,F,10*log10(abs(P)));
axis tight;
view(0,90);
file:///C:/Program%20Files/MATLAB/R2013a/help/signal/ref/spectrogram.html 21/01/2014
spectrogram Página 5 de 6
Examples
Compute and display the PSD of each segment of a quadratic chirp, which starts at
100 Hz and crosses 200 Hz at t = 1 sec.
T = 0:0.001:2;
X = chirp(T,100,1,200,'q');
spectrogram(X,128,120,128,1E3);
title('Quadratic Chirp');
Compute and display the PSD of each segment of a linear chirp, which starts at DC
and crosses 150 Hz at t = 1 sec.
T = 0:0.001:2;
X = chirp(T,0,1,150);
[S,F,T,P] = spectrogram(X,256,250,256,1E3);
surf(T,F,10*log10(P),'edgecolor','none'); axis
tight;
view(0,90);
xlabel('Time (Seconds)'); ylabel('Hz');
file:///C:/Program%20Files/MATLAB/R2013a/help/signal/ref/spectrogram.html 21/01/2014
spectrogram Página 6 de 6
More About
◾ Windows
References
[1] Oppenheim, A.V., and R.W. Schafer, Discrete-Time Signal Processing,
Prentice-Hall, Englewood Cliffs, NJ, 1989, pp.713-718.
[2] Rabiner, L.R., and R.W. Schafer, Digital Processing of Speech Signals,
Prentice-Hall, Englewood Cliffs, NJ, 1978.
See Also
goertzel | periodogram | pwelch | spectrum.periodogram |
spectrum.welch
file:///C:/Program%20Files/MATLAB/R2013a/help/signal/ref/spectrogram.html 21/01/2014