Download the file
signal.mat for the following section.
As previously stated, the short-time DTFT is a collection of
DTFTs that differ by the position of the truncating window.
This may be visualized as an image, called a
spectrogram.
A spectrogram shows
how the spectral characteristics of the signal evolve with time.
A spectrogram is created by placing the DTFTs vertically in
an image, allocating a different column for each time segment.
The convention is usually such that frequency increases from bottom
to top, and time increases from left to right.
The pixel value at each point in the image is proportional to the
magnitude (or squared magnitude) of the spectrum at a certain frequency
at some point in time.
A spectrogram may also use a “pseudo-color” mapping,
which uses a variety of colors to indicate the magnitude of the frequency
content, as shown in Figure 4.
For quasi-periodic signals like speech, spectrograms are placed into two
categories according to the length of the truncating window.
Wideband
spectrograms use a window with a length comparable to a single period.
This yields high resolution in the time domain but low resolution in
the frequency domain. These are usually characterized by vertical
striations, which correspond to high and low energy regions within a
single period of the waveform. In narrowband spectrograms, the window
is made long enough to capture several periods of the waveform. Here,
the resolution in time is sacrificed to give a higher resolution of the
spectral content. Harmonics of the fundamental frequency of the signal
are resolved, and can be seen as horizontal striations. Care should be
taken to keep the window short enough, such that the signal properties stay
relatively constant within the window.
Often when computing spectrograms, not every possible window shift position is used
from the stDTFT, as this would result in mostly redundant information.
Successive windows usually start many samples apart, which can be
specified in terms of the overlap between successive windows. Criteria in
deciding the amount of overlap include the length of the window, the
desired resolution in time, and the rate at which the signal
characteristics are changing with time.
Given this background, we would now like you to create a spectrogram
using your DFTwin()
function from the previous section.
You will do this by creating a matrix of windowed DFTs, oriented as
described above.
Your function should be of the form
A = Specgm(x,L,overlap,N)
where
x
is your input signal, L
is the window length, overlap is the number of points common to
successive windows, and N is the number of points you compute
in each DFT. Within your function, you should plot the
magnitude (in dB) of your spectrogram matrix using the command
imagesc(), and label the time and frequency axes appropriately.
- Remember that frequency in a spectrogram increases along the
positive y-axis, which means that the first few elements of each
column of the matrix will correspond to the highest frequencies.
- Your
DFTwin()
function returns the DT spectrum for frequencies
between 0 and 2π2π. Therefore, you will only need to use the
first or second half of these DFTs.
- The statement
B(:,n)
references the entire nthnth column
of the matrix BB.
- In labeling the axes of the image, assume a sampling frequency
of 8 KHz. Then the frequency will range from 0 to 4000 Hz.
- The
axis xy
command will be needed in order to
place the origin of your plot in the lower left corner.
- You can get a standard gray-scale mapping (darker means greater magnitude)
by using the command
colormap(1-gray)
, or a pseudo-color mapping
using the command colormap(jet)
.
For more information, see the online help for the
image
command.
Download the file
signal.mat, and load it into
Matlab. This is a raised square wave that is modulated by a sinusoid.
What would the spectrum of this signal look like?
Create both a wideband and a narrowband spectrogram using your
Specgm()
function for the signal.
- For the wideband spectrogram, use a window length of 40 samples
and an overlap of 20 samples.
- For
the narrowband spectrogram, use a window length of 320 samples, and an
overlap of 60 samples.
Subplot the wideband and narrowband spectrograms, and
the original signal in the same figure.
Hand in your code for Specgm() and your plots. Do you see vertical
striations in the wideband spectrogram? Similarly, do you see horizontal
striations in the narrowband spectrogram? In each case, what causes these
lines, and what does the spacing between them represent?