ELEC3004 Signals, Systems & Control
Semester 1, 2026
Tutorial 2
Sampling Theory, DTFT, DFT
1.1 The Nyquist Principle
The Nyquist sampling theorem is a fundamental result in signal processing that links continuous-time signal
and discrete-time signals. It gives a sufficient condition, under which a sampled signal can retain all the
information of a continuous-time signal of finite bandwidth.
Often we split this into two equivalent conditions from different perspectives of analysis.
The Nyquist rate (of a signal)
If a signal has a maximum frequency of fmax , then to avoid aliasing, it must be sampled at a rate greater
than twice this frequency.
fs > 2 · fmax = fN
This quantity 2fmax is called the Nyquist rate (or minimum sampling rate). It is a property of a signal, since
it is determined by the highest frequency present. The units for this are in samples · s−1 . Also note the strict
inequality.
The Nyquist frequency (of a sampling system)
On the other hand, if we already know the sampling rate of a system, and want to determine the highest
frequency that can be represented without aliasing, we use the Nyquist frequency (or folding frequency ),
defined as
fs
ffold =
2
This frequency can also be used to predict how a signal frequency will alias, i.e., what frequency it will alias
to. Unlike the Nyquist rate, this is a property of a sampling system. In practice, to meet this condition, a
signal should be band-limited before sampling through the use of a anti-aliasing low-pass filter.
In these exercises, we will look at different examples of aliasing through a range of signals including: a sine
wave, a square wave, and a chirp.
1
ELEC3004 Tutorial 2
Exercise 1.1. Open the MATLAB file ELEC3004 T2 Ex1.m or the Python file ELEC3004 T2 [Link].
In this script, we have a sine wave at a frequency of 440 Hz (a musical note A4).
We are sampling it at two sampling rates:
• 44.1 kHz
• 600 Hz
Before running the exercise:
i) Sketch the shape of the frequency spectrum.
ii) Predict what frequency the signal will alias to.
iii) Sketch the shape of the resulting spectrum.
Now, run the script pressing any key to proceed to the next part of the script.
iv) Reflect on how the result matches your prediction
v) Observe the pitch of the audio playback.
Exercise 1.2. Open the MATLAB file ELEC3004 T2 Ex2.m or the Python file ELEC3004 T2 [Link].
In this script, we have a square wave with a fundamental frequency of 220 Hz (one octave below the sine).
Recall that the Fourier series for a square wave is given by:
∞
4 X 1 4 X 1
f (t) = sin (2πf0 nt) = sin (2π (2k + 1) f0 t)
π n=1,3,5,...
n π 2k + 1
k=0
That is, we have odd harmonics with amplitudes inversely proportional to the frequency.
These harmonics continue on forever, and thus the square-wave is not band-limited.
In this exercise, we will observe the effects of sampling on a non-band-limited signal.
We will be sampling the square-wave at the following sampling rates:
fs ∈ {44.1 kHz, 4800 Hz, 2400 Hz, 1200 Hz, 600 Hz, 300 Hz}
iv) Is 44.1 kHz high enough to avoid aliasing theoretically and/or practically?
v) At what frequencies does this get significantly aliased?
vi) Is there anything you could do to the signal before sampling it to avoid aliasing?
Page 2
ELEC3004 Tutorial 2
Exercise 1.3. Open the MATLAB file ELEC3004 T2 Ex3.m or the Python file ELEC3004 T2 [Link].
This script generates a chirp signal, also known as a frequency sweep. This chirp begins at 20 Hz and increases
in frequency linearly until 10 kHz for a duration of 2 seconds.
We sample the chirp at two sampling rates:
• 44.1 kHz
• 8000 Hz
Then the signal is played-back, and analysed through a spectrogram (generated by computing a Short-time
Fourier transform, i.e., the STFT)
The last section of the script simply combines (averages) the two signals together so you can hear and visualise
the two signals together.
Before running the script
i) Predict the frequency at which the chirp signal will fold back.
ii) Is this folding periodic? Draw a diagram that describes the behaviour between input frequency and
output frequency.
Page 3
ELEC3004 Tutorial 2
Exercise 1.4. An input signal defined as x(t) is passed into a number of systems, and the output yi (t) will
be sampled.
The input signal has a maximum frequency of fmax,x . For each system, determine the minimum sampling
rate for the sampler to avoid aliasing.
Express your answer as an inequality, e.g. fs > ..., in terms of the input’s maximum frequency fmax,x . You
should also determine the Nyquist interval.
i) Time-reversal
y1 (t) = x(−t)
ii) Squaring
y2 (t) = x2 (t)
iii) Speed-up
y3 (t) = x(2t)
iv) Modulation
y4 (t) = x(t) · cos(2πf0 t)
Hence, determine the minimum sampling rate for these signals.
v) sinc(100πt)
vi) sinc2 (100πt)
vii) sinc(100πt) · cos (300πt)
Page 4
ELEC3004 Tutorial 2
Exercise 1.5. Consider the following real signals, with spectrum X(f ) given in Figure 1:
Figure 1: Spectrum of different signals
a) What is the Nyquist rate, fs to avoid aliasing when using a low-pass filter for reconstruction?
b) If the signal was sampled at 70000 samples/sec, what would happen? Will there be aliasing? If so,
what frequencies will alias?
c) Anti-aliasing filters have a transition band. If this signal is sampled at a sampling rate of 82 kHz, how
large a transition band does this sampling rate allow for the signal?
Page 5
ELEC3004 Tutorial 2
Exercise 1.6. Towards a perfect reconstruction of x(t) that is a combination of sinusoidal signals
1
x(t) = cos(2πt) + sin(5πt) + 4 cos 3π t +
4
a) What is the minimum sampling rate fs and the number of samples Ns that will allow resolution of all
the frequencies and their perfect reconstruction?
Hint: You may need to sample a whole period, and consider edge cases for the Nyquist limit.
b) If the signal is reconstructed with an ideal low-pass filter, what cut-off frequency should it have?
Exercise 1.7. A TV signal (video and audio) has a bandwidth of 4.5 MHz. This signal is sampled, quantized
and binary-coded to obtain a PCM (pulse code modulated) signal.
i) Determine the sampling rate if the signal is to be sampled at a rate 20% above the Nyquist rate.
ii) If the samples are quantized into 1024 levels, what number of binary pulses is required to encode each
sample.
iii) Determine the binary pulse rate (bits/s) of the binary coded signal.
Exercise 1.8. For the following signals:
i) x(t) = cos(4πt)
ii) x(t) = sin(4πt)
Please compute and sketch the sampled output x[n], sampled at the Nyquist rate for a period of T = 1 sec.
Page 6
ELEC3004 Tutorial 2
2 Discrete Fourier Transform
2.1 DFT Basis Transform
We can use the Discrete Fourier Transform to represent our signals in a new basis of sinusoids. Generally, the
DFT of our signal xn of length N can be calculated as
N −1
2πi
X
Xk = xn · e− N kn
n=0
But what does that actually mean? What does it have to do with bases? Well, to study that, we are going to
rewrite our DFT as a matrix transformation, just like the one we introduced before. It is possible to rewrite
this equation as
N −1 kn N −1 N −1
2πi
X X X
Xk = e− N · xn = wkn · xn = Wkn · xn
n=0 n=0 n=0
We can then write the transform as
X = Wx
Let’s start off with representing our signals. Because of the way imaginary numbers work, and the way
they are represented on the unit plane, we can show that some signal f (t) = e−iωt is equivalent to f (t) =
cos(ωt) − i sin(ωt). We will be using the exponential form from now on.
So now we want to invent the basis vectors for our DFT transform matrix. The way we do this is to say:
“Hey, we want each vector to be a sinusoid, so lets make each vector the sampled values of a sinusoid, and
each vector differs by the value of ω we use!”. We put these sampled sinusoid signals as the rows of a matrix
and we find that it’s the exact same computation as our DFT!1
For example, for a signal with 4 values, our vectors concatenated as rows of a 4 × 4 matrix creates:
0·0 0·1 0·2 0·3
e−2πi N e−2πi N e−2πi N e−2πi N
e−2πi 1·0
N
1·1
e−2πi N
1·2
e−2πi N
1·3
e−2πi N
e−2πi 2·0
N
2·1
e−2πi N
2·2
e−2πi N
2·3
e−2πi N
−2πi 3·0 3·1 3·2 3·3
e N e−2πi N e−2πi N e−2πi N
Where here, t = [0, 1, 2, 3]. And ω = 0, 41 , 24 , 43 .2
Substituting these in gives you the transformation matrix
1 1 1 1
1
−i −1 i
1 −1 1 −1
1 i −1 −i
Note that this isn’t an orthonormal transformation, just orthogonal. It needs to be scaled by √1N to be
orthonormal, but we will do this later because it’s easier for now. Generally we don’t scale it at all and just
add a scaling factor to the inverse transform.
You can watch the animated video on Blackboard, which goes through this process.
1 We do this because it’s essentially taking the inner product/dot product of our signal with our sinusoid basis vectors, with
the resulting values being our DFT values. A bigger inner product value for a specific basis vector meaning more of the signal
being aligned with that vector, hence having more of that sinusoid.
Page 7
ELEC3004 Tutorial 2
2.2 An Example
To test this out, let’s find the DFT of the relatively simply vector:
0
1
x= 0
−1
π
This is a discrete sine wave given by the function xn = sin 2n . If we push this through MATLAB we get the
vector:
0
−2i
X=
0
2i
You can calculate this using the formula from earlier to check this result.
If we then use the inverse DFT, given by the equation2
N −1
1 X 2πi
xn = Xk · e N nk
N
k=0
we can see how these Fourier coefficients form the sinusoidal signal.
3
1X 2πi
xn = Xk · e 4 nk
4
k=0
1 2πi 4πi 6πi
= 0 · e0·n − 2i · e 4 n + 0 · e 4 n + 2i · e 4 n
4
1 2πi 6πi
= −2i · e 4 n + 2i · e 4 n
4
[e−2πin = 1]
1 2πi 6πi
= −2i · e 4 n + 2i · e 4 n · e−2πin
4
1 2πi 6πi 8πi
= −2i · e 4 n + 2i · e 4 n · e− 4 n
4
1 2πi 2πi
= −2i · e 4 n + 2i · e− 4 n
4
πi πi
e 2 n − e− 2 n
=
πn2i
= sin
2
You can show the final two steps using Euler’s Formula
πi πi
e − e− 2 n
2 n
xn =
2i
cos πn πn
− cos − πn − i sin − πn
2 + i sin 2 2 2
=
2i πn
cos πn πn
− cos 2 + i sin πn
2 + i sin 2 2
=
2i
i sin πn πn
2 + i sin 2
=
2i
2i sin πn
2
=
2i
πn
= sin
2
2 Notice how it’s the same as the DFT but the sinusoid goes the other way (sign of the index is changed) and there’s a
1
normalising factor of N
Page 8
ELEC3004 Tutorial 2
Exercise 2.1. DFT and IDFT
Given
x= 1 0 −1 0
Calculate the DFT X by hand, and convert it back to x using the IDFT. Check your results using the MATLAB
commands fft and ifft. Compare this to the previous section, and discuss.
MATLAB Code for FFT
% DFT in MATLAB using FFT
>> X = fft([1, 0, -1, 0])
X =
0 2 0 2
% Now run IDFT using IFFT, we get our original vector
>> x = ifft(X)
x =
1 0 -1 0
Python Code for FFT
# DFT in Python using FFT
>>> import numpy as np
>>> from [Link] import fft, ifft
>>> X = fft([Link]([1, 0, -1, 0]))
>>> X
array([0.-0.j, 2.+0.j, 0.-0.j, 2.-0.j])
# Now run IDFT using IFFT, we get our original vector
>>> x = ifft(X)
>>> x
array([ 1.+0.j, 0.+0.j, -1.-0.j, 0.+0.j])
Discussion: Linearity
Is the DFT a linear transformation? What does this mean? How is this useful when analysing the DFT of a
particular signal? Relate this to the linear independence of sinusoids of frequencies.
Discussion: Invertibility
Is the DFT always perfectly invertible? If say, you want to perform an operation in the frequency domain, like
removing a particular frequency component, can you recreate the time domain signal? What constraints do
you need to ensure that a real-valued signal is produced?
Exercise 2.2. Orthogonal Signals
Given
x1 [n] = 0 1 0 −1 , x2 [n] = 1 0 −1 0
Calculate the inner product ⟨x1 , x2 ⟩ and determine whether or not they are orthogonal. Take the DFT (by
hand or through MATLAB) and calculate the inner product ⟨X1 , X2 ⟩ in the frequency domain and do the same
analysis. Explain your answer.
Page 9
ELEC3004 Tutorial 2
3 Using MATLAB to do digital signal processing
3.1 Helpful functions
MATLAB and Python are going to be of immense use in any real world signal processing application. Here
are some functions you should know, that may be useful for your problem set solutions.
fft / [Link]
The Discrete Fourier Transform of a signal, implemented through a Fast Fourier Transform algorithm
ifft / [Link]
The inverse Discrete Fourier Transform of a signal, implemented through a Fast Fourier Transform algorithm
dftmtx
The matrix equivalent of a Discrete Fourier Transform operation.
fftshift / [Link]
The DFT of a signal has components in both ω > 0 and ω < 0. By default, MATLAB shifts the ω < 0 to
the end of the DFT array so that zero and positive frequencies come first. This function shifts it so that DC
(0 Hz) is in the middle of the array. It is useful for visualising the frequency spectrum.
ifftshift / [Link]
This does the inverse of fftshift to bring the original spectrum back.
real / [Link] and imag / [Link]
The real/imaginary components of the input vector. Useful for looking at both parts of a Fourier Transform.
Exercise 3.1.
1. Write a MATLAB/Python function to calculate the Discrete Fourier Transform of a signal by running
through the DFT calculation.
2. Write a MATLAB/Python function to compute the DFT matrix. Start with the straightforward way,
but see if you can find a more elegant method. Hint: What’s the Fourier transform of a basis vector?
3. Take the FFT of a variety of different signals with different properties. Consider a combination of real
and imaginary signals, and odd and even signals. See if you can notice any patterns. You can use
signals with only 4 elements for simplicity
N −1
2πi
X
Xk = xn · e− N kn
n=0
Page 10
ELEC3004 Tutorial 2
Exercise 3.2. We may use one of the following Fourier representations to transform a signal from time to
frequency domain:
• Fourier Series (FS)
• Fourier Transform (FT)
• Discrete Fourier Transform (DFT)
• Discrete Time Fourier Transform (DTFT)
Briefly explain the difference between them.
Page 11