Digital Signal Processing - Exercises: 1 Sequences and Systems
Digital Signal Processing - Exercises: 1 Sequences and Systems
– exercises
Markus Kuhn
Michaelmas 2019
CST Part II(50%) only
Some of the exercises involve writing very short programs (< 20 lines). Preferably use
MATLAB, Octave, or a similar technical-computing language. A MATLAB campus li-
cence is available at
https://www.cl.cam.ac.uk/teaching/matlab/
Please hand in both your source code and its output. Some tips to help this go smoothly:
• Start every program with a comment (%) that states your name, the exercise number,
and the approximate time in minutes it took you to write it.
• Provide figures generated by your program in PDF. In MATLAB this can be done
with saveas(gcf, 'mgk25-ex10.pdf'). You can also save both source code and
its output into one PDF with a command like publish('mgk25-ex10.m', 'pdf').
• Test your MATLAB programs after a clear instruction, to avoid it depending on
other variables left in your workspace.
1
2 Convolution
Exercise 2:
Prove that convolution is
(a) commutative
(b) associative
(c) Use the MATLAB/Octave facilities for solving systems of linear equations to undo
the above convolution step.
Exercise 6:
(a) Find a pair of sequences {an } and {bn }, where each one contains at least three
different values and where the convolution {an }∗{bn } results in an all-zero sequence.
(b) Does every LTI system T have an inverse LTI system T −1 such that {xn } =
T −1 T {xn } for all sequences {xn }? Why?
2
3 Fourier transform
4 Sampling
Exercise 7: Digital-to-analog converters cannot output Dirac pulses. Instead, for each
sample, they hold the output voltage (approximately) constant, until the next sample
arrives. How can this behaviour be modeled mathematically as a linear time-invariant
system, and how does it affect the spectrum of the output signal?
Exercise 8: Many DSP systems use “oversampling” to lessen the requirements on the
design of an analog reconstruction filter. They use (a finite approximation of) the sinc-
interpolation formula to multiply the sampling frequency fs of the initial sampled signal
by a factor N before passing it to the digital-to-analog converter. While this requires more
CPU operations and a faster D/A converter, the requirements on the subsequently applied
analog reconstruction filter are much less stringent. Explain why, and draw schematic
representations of the signal spectrum before and after all the relevant signal-processing
steps.
Exercise 9: Similarly, explain how oversampling can be applied to lessen the require-
ments on the design of an analog anti-aliasing filter.
Exercise 10:
(a) Simulate the reconstruction a sampled base-band signal in MATLAB/Octave, fol-
lowing these steps:
• Generate a one second long Gaussian noise sequence {rn } (using MATLAB
function randn) with a sampling rate of 300 Hz.
• Use the fir1(50, 45/150) function to design a finite impulse response low-
pass filter with a cut-off frequency of 45 Hz. Use the filtfilt function in
order to apply that filter to the generated noise signal, resulting in the filtered
noise signal {xn }.
• Then sample {xn } at 100 Hz by setting all but every third sample value to
zero, resulting in sequence {yn }.
• Generate another low-pass filter with a cut-off frequency of 50 Hz and apply
it to {yn }, in order to interpolate the reconstructed filtered noise signal {zn }.
Multiply the result by three, to compensate the energy lost during sampling.
• Plot {xn }, {yn }, and {zn }, all on top of each other in one figure, and compare
{xn } with {zn }.
(b) Why should the first filter have a lower cut-off frequency than the second?
3
Exercise 11:
(a) Simulate the reconstruction of a sampled band-pass signal in MATLAB/Octave,
following these steps:
• Generate a 1 s noise sequence {rn }, as in exercise 10, but this time use a
sampling frequency of 3 kHz.
• Apply to that a band-pass filter that attenuates frequencies outside the interval
31–44 Hz, which the MATLAB Signal Processing Toolbox function cheby2(3,
30, [31 44]/1500) will design for you.
• Then sample the resulting signal at 30 Hz by setting all but every 100-th sample
value to zero.
• Generate with cheby2(3, 20, [30 45]/1500) another band-pass filter for the
interval 30–45 Hz and apply it to the above 30-Hz-sampled signal, to recon-
struct the original signal. (You’ll have to multiply it by 100, to compensate
the energy lost during sampling.)
• Plot all the produced sequences and compare the original band-pass signal and
that reconstructed after being sampled at 30 Hz.
(b) Why does the reconstructed waveform differ much more from the original if you
reduce the cut-off frequencies of both band-pass filters by 5 Hz?
6 Deconvolution
Exercise 13: Use MATLAB to deconvolve the blurred stars from slide 31.
The files stars-blurred.png with the blurred-stars image and stars-psf.png with the
impulse response (point-spread function) are available on the course-material web page.
You may find the MATLAB functions imread, double, imagesc, circshift, fft2, ifft2
of use.
Try different ways to control the noise (slide 88) and distortions near the margins (win-
dowing). [The MATLAB image processing toolbox provides ready-made “professional”
functions deconvwnr, deconvreg, deconvlucy, edgetaper, for such tasks. Do not use
these, except perhaps to compare their outputs with the results of your own attempts.]
4
7 Spectral estimation
Exercise 14: Analog touch tone push-button telephones use a system called dual-tone
multi-frequency signaling (DTMF) to communicate to the telephone switch which button
is being pressed. Each button produces a combination of two sine tones:
1209 Hz 1336 Hz 1477 Hz 1633 Hz
697 Hz 1 2 3 A
770 Hz 4 5 6 B
852 Hz 7 8 9 C
941 Hz * 0 # D
(a) You receive a digital telephone signal with a sampling frequency of 8 kHz. You
cut a 256-sample window out of this sequence, multiply it with a windowing func-
tion and apply a 256-point DFT. What are the indices where the resulting vector
(X0 , X1 , . . . , X255 ) will show the highest amplitude if button 9 was pushed at the
time of the recording?
(b) The audio file touchtone.wav on the course-materials web page contains the record-
ing of a DTMF-encoded sequence of buttons pressed on a telephone. Use the short-
term Fourier transform, as implemented by MATLAB’s spectrogram function, to
produce a spectrogram image. Chose a window size that provides a good visual
tradeoff for the resulting time and frequency resolution. Then read off which touch-
tone button sequence was typed.
8 Digital filters
5
9 IIR filters
Exercise 16: Draw the direct form II block diagrams of the causal infinite-impulse re-
sponse filters described by the following z-transforms and write down a formula describing
their time-domain impulse responses hi :
1
(a) H(z) =
1 − 12 z −1
0 1 − 414 z −4
(b) H (z) =
1 − 14 z −1
1 1 −1 1 −2
(c) H 00 (z) = + z + z
2 4 2
Exercise 17:
(a) Perform the polynomial division of the rational function given in exercise 16 (a)
until you have found the coefficient of z −5 in the result.
(b) Perform the polynomial division of the rational function given in exercise 16 (b)
until you have found the coefficient of z −10 in the result.
(c) Use its z-transform to show that the filter in exercise 16 (b) has actually a finite
impulse response and draw the corresponding block diagram.
Exercise 18: Consider the system h : {xn } → {yn } with yn + yn−1 = xn − xn−4 .
(a) Draw the direct form I block diagram of a digital filter that realises h.
(b) What is the impulse response of h?
(c) What is the step response of h (i.e., h ∗ u)?
(d ) Apply the z-transform to (the impulse response of) h to express it as a rational
function H(z).
(e) Can you eliminate a common factor from numerator and denominator? What does
this mean?
(f ) For what values z ∈ C is H(z) = 0?
(g) How many poles does H have in the complex plane?
(h) Write H as a fraction using the position of its poles and zeros and draw their location
in relation to the complex unit circle.
(i ) If h is applied to a sound file with a sampling frequency of 8000 Hz, sine waves
of what frequency will be eliminated and sine waves of what frequency will be
quadrupled in their amplitude?
6
10 Random signals
11 Digital communication
11.1 IQ sampling
Exercise 19: FM demodulation of a single radio station from IQ data:
• The file iq-fm-96M-240k.dat (on the course web page) contains 20 seconds of a
BBC Radio Cambridgeshire FM broadcast, IQ sampled at the transmitter’s centre
frequency of 96.0 MHz, at a sample rate of 240 kHz, after having been filtered to
192 kHz bandwidth.
• Load the IQ samples into MATLAB using
f = fopen('iq-fm-96M-240k.dat', 'r', 'ieee-le');
c = fread(f, [2,inf], '*float32');
fclose(f);
z = c(1,:) + 1j*c(2,:);
• FM demodulate the complex baseband radio signal z (using angle)
• apply a 16 kHz low-pass filter (using butter, filter)
• reduce the sample rate from 240 kHz down to 48 kHz (keep only every 5th sample
using the : operator)
• normalize amplitude (−1 . . . + 1), output as WAV (audiowrite), listen