Académique Documents
Professionnel Documents
Culture Documents
Learning outcomes
• Use the continuous Fourier Transform to perform frequency analysis on a
continuous (analogue) non-periodic signal;
• Use the Discrete Fourier Transform to perform frequency analysis on a
discrete (digital) signal;
• Explain the significance of the Fast Fourier Transform algorithm;
• Explain why windowing is important in most real-world frequency analysis.
Equations (9) and (10) can be used instead of eqns (1) and (7). At first, this might
seem like an unnecessary complication, but the complex representation of eqn’s (9)
and (10) has advantages:
The second point above could do with some explanation. When we do a Fourier
Analysis using eq’n (7) on a periodic signal which is neither odd nor even, we end up
with two sets of coefficients, the an’s and the bn’s. When we listen to a periodic sound,
however (perhaps a musical note) we only hear one frequency spectrum. So we have
to combine the an’s and the bn’s to get the total contribution at each frequency. We
noted earlier that we do this by introducing:
The LHS of eqn (8) is, of course, the magnitude of the complex coefficient used in
eqns (9) and (10). So, the complex exponential form of the Fourier Series
automatically gives us the thing which is usually most perceptually relevant to the
listener. The phase of the signal v(t) at each harmonic frequency is given by the
argument of each complex coefficient Cn:
b
∠C n = tan −1 n (11)
an
So far we have seen how useful Fourier Analysis is for doing frequency analysis on
periodic signals. But many signals are non-periodic – a spoken word, a single
drumbeat or an aircraft overflight, for example. Assuming we have recorded one of
these, how can we find out what frequencies it contains? We can approach this
problem by looking again at our Fourier Analysis of the pulse train,
−w w
1, <t <
2 2
−T − w
y (t ) = 0, <t<
2 2
0, w T
<t <
2 2
1.2
0.8
) 0.6
t
(
y 0.4
0.2
-0.2
0 T 2T
time, t
If we do the complex Fourier Analysis this time – that is, apply eqn. (10) – we find
that
If we then leave the pulse width unchanged and increase the period of the signal, so
that the pulses are now spaced apart by 30 ms, the frequency spectrum changes to the
top right panel of the graph. As we continue to move the pulses further and further
apart, the period T1 lengthens and the spectrum becomes more and more dense. In
fact, the spacing of the spectral lines is simply the inverse of the period:
1
∆f = (12)
T1
where ∆ f is the distance in Hz between one harmonic line and the next.
When T1 is 300 ms, we can no longer discern individual harmonic lines in the graph.
Clearly, as the spacing of the pulses in the time domain is increased, the number of
components in the frequency domain increases. The limit of this process would be to
extend the pulse spacing to infinity, so that we had only one pulse in the time domain.
We would then expect the harmonics in the frequency domain to be so closely packed
together that they were no longer individual lines, but a continuous function of
frequency. A single pulse can not be a periodic signal, so this leads us towards a way
∫ x(t ) e
− jwt
X (v ) = dt (13)
−∞
There is another equation which reverses the transform and takes us from the
frequency domain back to the time domain:
∞
1
x (t ) =
2π ∫
−∞
X (ϖ )e jωt dϖ (14)
Equations (13) and (14) can be used on any signal, periodic or non-periodic. They
form the basis of the huge field of modern signal processing.
0.8
)
t
( 0.6
x
0.4
0.2
0
0
Time, t
t
− 1 − jw t 2
= e
jw −t
2
−1
− jw t jw t
= e 2
−e 2
jw
−1 w t wt w t w t
= c o s − + j sin − − co s − j sin
jw 2 2 2 2
−1 w t w t w t w t
= c o s − co s − j sin − j sin
jw 2 2 2 2
2 w t
= sin
w 2
w t
sin
1 2
=
t w t
2
sin( y)
The function appears so often in maths that it has its own name: sinc. Thus,
y
we can write the Fourier Transform of the rectangular pulse as
1 wt
X (v ) = sinc
t 2
Note that, in this case, X(ω ) turns out to be real (it has no imaginary part). This is a
consequence of our defining x(t) as an even function. When we come to plot X(ω ) we
would normally have to decide whether to plot the magnitude (frequency spectrum) or
phase. In this case, the phase is zero, so we can directly plot X against frequency:
1\tau
)
f
(
X
0 1\tau
Frequency, f
Note that:
• the spectrum X(f) is a continuous function of frequency, not a series of spikes
at individual harmonics (as is the case for the Fourier Series of a periodic
signal);
• the sinc function produces a spectrum with ripples;
• as f → 0, sinc(f) → 1
• X(f) has zeroes when the frequency is at integer multiples of 1/τ
• we can broaden the first lobe of the spectrum by reducing the pulse width τ ,
thus:
)
f
(
X
0 1\tau
Frequency, f
This last result leads us towards the idea of making the pulse ever more narrow. We
could continue to do this until we have a pulse which has a height of 1 only at the
exact point when t = 0. That is,
1, t = 0
x(t ) =
0, elsewhere
In the early 20th century, a physicist called Paul Dirac defined such a function and
called it the delta function. (It is sometimes referred to in his honour as the Dirac
delta function.)
1, t = 0
d (t ) = (15)
0, elsewhere
1
)
t
(
a
t
l
e
d
0
0
time, t
The delta function is a strange beast. For a start, it is not practically realisable as a
signal – we can only approximate it with a very very narrow pulse. But it is worth
approximating, since it has some very useful properties. Later on, you will probably
meet several of these properties, but we will introduce one here: the sifting property.
The delta function sifts out a particular value of a function inside an integral:
Equation (16) picks out the value of function f at t = 0. If we want to pick out a value
of f at some arbitrary value of t, which we’ll call t0, then we must use a delta function
centred on t0:
The sifting property is strange and, perhaps, interesting, but what use is it? It has
several applications: one is that it allows us to calculate the FT of a delta function
very easily:
∫ δ (τ) ε
− ϕωτ
∆(ϖ ) = δτ
−∞
= ε − ϕω 0
= 1
The FT of the delta function is a constant! This tells us that a delta function of time is
composed of all frequencies present in equal amplitude and phase. This makes a delta
function a (theoretically) good signal for testing a signal-processing device such as an
amplifier, filter or loudspeaker. This is because a response to a single delta function
contains a description of the response to all possible sinusoidal frequency
components.
So far we have dealt with continuous signals. We can now (finally!) start to process
some discrete (digital) signals. Equation (18) below defines the Discrete Fourier
Transform:
N −1 − j 2p mk
X m = ∑ xk e N
(18)
k =0
Note that this is similar to the continuous Fourier Transform defined in eqn. (13)
except that:
• the continuous function of time x(t) (our signal) is replaced by the time
sequence xk
• continuous time t is replaced by time index (or sample number) k which
takes values 0, 1, 2, …N-1
• the length of the signal (or of the chunk being transformed) is N samples
• the integral is replaced by a summation
• the continuous function of frequency X(ω ) is replaced by the frequency
sequence Xm
• continuous frequency f is replaced by frequency index m which takes values
0, 1, 2, …N-1
N −1 j 2p mk
1
xk =
N
∑ X me
m =0
N
(19)
0.8
0.6
x 0.4
0.2
-0.2
0 1 2 3 4 5
k
To calculate the DFT of this signal, we have to find each value of X in turn; first X0,
then X1 and so on:
5 − ϕ2π 0 κ 5
Ξ 0 = ∑ ξκ ε 6
=∑ ξκ = ξ0 + ξ1 + ξ2 + ξ3 + ξ4 + ξ5 = 3
κ= 0 κ= 0
5 − ϕ2π 1κ − ϕ2π 0 − ϕ2π 1 − ϕ2π 2 − ϕπ − ϕ2π
Ξ 1 = ∑ ξκ ε 6
= ξ0 ε 6
+ ξ1ε 6
+ ξ2 ε 6
= 1+ ε 3
+ε 3
κ=0
We can reduce the amount of algebra here by defining a new variable. Let
− jπ
z=e 3
= 0.5 − j 0.866
j 2π
z is periodic with a period of 6 (because e - is periodic with a period of 1). This
helps us to evaluate:
z =e
2 3
= −0.5 − j 0.866
z 3 = e − jπ = 1
z 4 = z − 2 = −0.5 + j 0.866
z 5 = z −1 = 0.5 + j 0.866
z6 = z0 = 1
z8 = z 2
z 10 = z 4
Similarly,
5 − ϕ2π 2 κ 5
Ξ 2 = ∑ ξκ ε 6
= ∑ ξκ ζ2 κ = ξ0 ζ0 + ξ1 ζ2 + ξ2 ζ4 = ζ0 + ζ2 + ζ4
κ= 0 κ= 0
2.5
|
X 1.5
|
1
0.5
0
0 1 2 3 4 5
m
0.5
)
X 0
(
g -0.5
r
a -1
-1.5
-2
-2.5
0 1 2 3 4 5
m
Calculating the DFT for our six-point signal above was quite a lot of work. Most real
digital signals, though, are much longer. A signal of 1,000 points or even 1,000,000
points is quite usual. But the number of (complex) multiplications required to find the
DFT of an N-point signal is N 2. What if we take one second of signal from an audio
CD and we want to know what the frequency content of that one second is? That’s
44,000 sample points. Clearly, we need an automated method to calculate the DFT!
It would be quite possible (and not very hard) to write a computer program to
calculate the DFT directly. But this would still be slow. Modern signal procesing
often demands that the spectrum be calculated in real time - that is, the spectrum
display is updated continuously as new signal values arrive. This sort of speed
requires a very efficient algorithm to calculate the DFT. Fortunately for us, one exists.
The Fast Fourier Transform is a matrix-based algorithm for calculating the DFT,
discovered by a number of independent workers in the 1950’s. It is the cornerstone of
modern signal processing.
You can read about how the FFT works in just about any text on digital signal
processing – we need not concern ourselves with its workings here. Implementations
of it exist in most programming languages as subroutines or functions. One of the
main reasons for using Matlab for this course, though, is that Matlab comes with the
FFT built in. This makes it very quick and easy to obtain the spectrum of a signal. For
example, to generate the short pulse in the example above and obtain its spectrum
took only the following lines in Matlab:
That is, the number of points in the time domain signal must be equal to an integer
power of 2. Common FFT sizes are 512, 1024, 2048 points. There are other
algorithms available for computing a DFT when this condition on N is not satisfied,
but they are much less efficient than the FFT. (Matlab will automatically use the best
algorithm for the size of signal you give it, but it will be much faster if N is a power of
2.)
The FFT is so ubiquitous that its name is often used in place of the DFT – this is,
strictly speaking, incorrect. The DFT is the mathematical transform that allows us to
take a digital signal in the time domain and transform it to the frequency domain. The
FFT is just an efficient way of doing the DFT.
Now that we have a way of transforming longer signals, let’s look at the spectrum of a
pulse with a few more sample points:
1, 0 ≤ k ≤ 7
yk =
0, 8 ≤ k ≤ 1023
1.2
0.8
0.6
y 0.4
0.2
-0.2
0 200 400 600 800 1000
k
5
|
Y 4
|
3
0
0 200 400 600 800 1000 1200
m
The symmetry is a feature of the DFT. It is also present in the first example which we
calculated by hand. In fact, only the first half of the spectrum has physical meaning.
(The RH half is sometimes interpreted as existing at negative frequencies, but these
will not concern us on this module.) Thus, though we put N points of information into
the DFT (or FFT), we only get N/2 points back out.
So far, we have not said anything about how our time signal samples are spaced in
time (other than that they must be regularly spaced). If we do specify the sampling
rate, though, we can put units on both the time axis and the frequency axis of our
plots.
Let the sampling frequency of our time signal xk be fs so that the time interval from
one sample point to the next is
1
τ =
fs
The signal then covers the time range from 0 to (N-1)τ seconds.
Hence the maximum useable frequency in the DFT is fs/2 - the Nyquist frequency!
(Remember that we only use the first half of the mirrored spectrum.)
For example, if we set the sampling rate of the pulse above at, say, 10 kHz, then we
can replot the graphs against time and frequency respectively:
1.2
0.8
0.6
y 0.4
0.2
-0.2
0 0.02 0.04 0.06 0.08 0.1
time (s)
8
5
|
Y 4
|
3
0
0 1000 2000 3000 4000 5000
frequency (Hz)
The example we have used so far, the single rectangular pulse, is short enough that we
can fit the whole signal nicely into our analysis frame for the FFT. In fact, in the later
examples, I deliberately chose the length of the signal to be 1024 points, a convenient
size for the FFT algorithm. Most real-world signals are not like this. Very often, we
wish to extract part of a long signal and perform frequency analysis on it (not least
because execution times for the FFT rise with the number of points being
transformed).
x(t) 0.5
0
-0.5
-1
0 0.2 0.4 0.6 0.8 1
t (s)
|X(f)| 40
(dB) 20
0
-20
-40
0 20 40 60 80 100
f (Hz)
What we need is a window which does not suddenly cut off the signal at its edges, but
rather one which smooths the signal gradually down to zero at its edges. One
candidate for this is called the Hamming window. This is defined by
2πk
hk = 0.54 − 0.46 χοσ , 0≤k ≤N
N −1
w
o 1
d
n
i 0.8
w
g 0.6
n
i
m 0.4
m
a
H 0.2
0 20 40 60 80 100
k
Comparing the two windows, we can see that the Hamming window will smooth the
data more effectively than the rectangular window.
w
o
d
n
i 1
w
r 0.8
a
l
u 0.6
g
n
a 0.4
t
c
e 0.2
R
0 20 40 60 80 100
k
Now look at the spectrum of the sine wave again. This time, the signal is multiplied
by a Hamming window before the FFT is taken:
x(t) 0.5
0
-0.5
-1
0 0.2 0.4 0.6 0.8 1
t (s)
|X(f)| 40
(dB) 20
0
-20
-40
0 20 40 60 80 100
f (Hz)
While not perfect, the spectrum is much improved – we can see that most of the
energy is at he expected peak at 10 Hz.
(By the way, the plots demontrating the effects of windowing were taken from one of
Matlab’s own demos. You can run these yourself, if you have a version of Matlab
with the Signal Processing Toolbox installed. To do this, go to Help, Examples and
Demos, then double-click on Toolboxes.)
1. Find the Fourier Transform of the following signal. Sketch a graph of the signal
and one of the magnitude of its frequency spectrum.
2. Find the Fourier Transform of the following signal. Sketch a graph of the signal
and one of the magnitude of its frequency spectrum.
x (t ) = δ (t ) + δ (t − t 0 ) where t0 is a constant.