Vous êtes sur la page 1sur 19

Weeks 3-5: The Fourier Transform

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.

The Complex Fourier Series

Now, so far, we have expressed Fourier Series in trigonometric form:



v (t ) = a 0 + ∑ a n cos( nv 1t ) + bn sin( nv 1t ) (1)
n =1

From Euler’s Theorem, we know that


e jθ = cos θ + j sin θ
where θ is in radians.

Using Euler’s Theorem, we can express the F.S. as a complex exponential:



v (t ) = ∑C
n = −∞
n e jn v 1t (9)
where the (complex) coefficients Cn are calculated by:
T1
2
1
∫ v(t ) e
− jn w1t
Cn = dt (10)
T1 −T1
2

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:

• Only one integral to do in Fourier Analysis to get the coefficients Cn (instead


of three for the trig form);
• Better representation of the interesting parameters of the Fourier Series;
• Leads directly on to the powerful Fourier Transform.

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:

DTAA notes (WJD) Fourier Transform 1


2 2
a n + bn
Cn = (8)
2

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 

Frequency Analysis of Non-Periodic Signals: The Fourier Transform

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

DTAA notes (WJD) Fourier Transform 2


1  nv 1 w 
Cn = sin  
np  2 
as we expect.
C C
Now let us consider what happens if we slow the frequency of the pulses down, so
, ,
that tthey get further apart. Imagine that wet begin with a period T1 of 10 ms (so that
the fundamental
n frequency f1 is 100 Hz) and
n a pulse width w of 0.5 ms. Then the
e
frequency
i
spectrum given by our Fourier eiAnalysis would look like the top left panel
in the
c graph below: c
i i
f f
f Frequency spectrum for T = 10 ms f Frequency spectrum for T = 30 ms
e 0.06 e 0.02
on on
c C c C0.015
0.04
r , r ,
e t e t 0.01
i 0.02
n i n
r e r e0.005
u i u i
o c o c
0 0
F i 0 1000 2000 F i 0 1000 2000
f Frequency (Hz) f Frequency (Hz)
f Frequency
x 10
-3 spectrum for T = 100 ms f Frequency
x 10
-3 spectrum for T = 300 ms
e 6 e 2
on on
c c 1.5
4
r r
e e 1
i 2 i
r r 0.5
u u
o o
F 00 1000 2000 F
0
0 1000 2000
Frequency (Hz) Frequency (Hz)

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

DTAA notes (WJD) Fourier Transform 3


of calculating a frequency spectrum for a non-periodic signal. In such a case, eqn.
(10) would then become:

∫ x(t ) e
− jwt
X (v ) = dt (13)
−∞

X is called the Fourier Transform of the signal x. Note that:


• X is like the Fourier Series coefficients Cn except that it is a continuous
function of frequency ω
• The limits of the integral are now infinite (in practice this means that the
integral should be computed for as long as the signal x exists)
• Eqn (13) transforms from the time domain representation of the signal x(t) to
the frequency domain representation of the signal X(ω )

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.

Fourier Transform Example: A Single Rectangular Pulse

We define a signal consisting of a single pulse of width τ seconds:


 −t t
1, <t< 
x(t ) =  2 2
 0, elsewhere

DTAA notes (WJD) Fourier Transform 4


A single rectangular pulse
1.2
→ τ←
1

0.8
)
t
( 0.6
x
0.4

0.2

0
0
Time, t

Then we substitute the definition of x(t) into eqn (13):

DTAA notes (WJD) Fourier Transform 5


t
2
X (v ) = ∫ e − jwt d t
t

2

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:

DTAA notes (WJD) Fourier Transform 6


Frequency spectrum of a single rectangular pulse

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:

Frequency spectrum of a narrower pulse


1\tau

)
f
(
X

0 1\tau
Frequency, f

DTAA notes (WJD) Fourier Transform 7


The Dirac delta function

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 

The delta function is usually drawn as a vertical line:

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:

∫ d (t ) f (t )dt = f (0) (16)

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:

DTAA notes (WJD) Fourier Transform 8


∫ d (t − t 0 ) f (t ) dt = f (t 0 ) (17)

The Fourier Transform of a delta function

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.

The Discrete Fourier Transform

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

There is a corresponding Inverse Discrete Fourier Transform which takes a

DTAA notes (WJD) Fourier Transform 9


frequency spectrum and turns it back into a time signal:

N −1 j 2p mk
1
xk =
N
∑ X me
m =0
N
(19)

DFT Example: A Rectangular Pulse

Consider this simple finite pulse:


ξ0 = 1
ξ1 = 1
ξ2 = 1
ξ3 = 0
ξ4 = 0
ξ5 = 0
1.2

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:

DTAA notes (WJD) Fourier Transform 10


− j 2π

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

Using these substitutions in our DFT calculations, we have:


X 1 = 1 + z + z 2 = 1 + 0.5 − j 0.866 − 0.5 − j 0.866 = 1 − j1.732

Similarly,
5 − ϕ2π 2 κ 5
Ξ 2 = ∑ ξκ ε 6
= ∑ ξκ ζ2 κ = ξ0 ζ0 + ξ1 ζ2 + ξ2 ζ4 = ζ0 + ζ2 + ζ4
κ= 0 κ= 0

= 1 − 0.5 − ϕ0.866 − 0.5 + ϕ0.866 = 0


5
Ξ 3 = ∑ ξκ ζ3κ = ξ0 ζ0 + ξ1 ζ3 + ξ2 ζ6 = ζ0 + ζ3 + ζ6
κ= 0

= 1 − 0.5 − ϕ0.866 − 0.5 + ϕ0.866 = 0


5
Ξ 4 = ∑ ξκ ζ4 κ = ζ0 + ζ4 + ζ8 = 1 − 0.5 + ϕ0.866 − 0.5 − ϕ0.866 = 0
κ= 0
5
X 5 = ∑ x k z 5 k = z 0 + z 5 + z 10 = 1 + 0.5 + j 0.866 − 0.5 + j 0.866 = 1 + j1.732
k =0

We can now plot the magnitude spectrum:

2.5

|
X 1.5
|
1

0.5

0
0 1 2 3 4 5
m

… and the phase spectrum:

DTAA notes (WJD) Fourier Transform 11


1.5

0.5
)
X 0
(
g -0.5
r
a -1

-1.5

-2

-2.5
0 1 2 3 4 5
m

The Fast Fourier Transform

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:

x = zeros(6,1); % initialise x to have six values, all 0


x(1:3) = ones(3,1); % then set the first 3 values to 1
X = fft(x); % find the DFT of x

DTAA notes (WJD) Fourier Transform 12


There is one restriction on the FFT algorithm:
N = 2p , p integer

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.

FFT Example: The Rectangular Pulse Revisited

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

Taking the FFT of this signal and ploting the magnitude:

DTAA notes (WJD) Fourier Transform 13


8

5
|
Y 4
|
3

0
0 200 400 600 800 1000 1200
m

We notice two things about this spectrum plot:


• it is symmetrical
• the first half of it looks like the absolute value of the sinc function we saw in
the spectrum of the periodic rectangular pulse train earlier.

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.

Frequency resolution and sampling rate

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.

The frequency resolution, or the spacing between consecutive points of Xm is given by


1 φσ
∆φ = = (20)
( Ν − 1)τ Ν −1

DTAA notes (WJD) Fourier Transform 14


The N points of the DFT Xm must cover the frequency range from 0 Hz to a maximum
frequency of ( N − 1) ∆f = f s

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)

DTAA notes (WJD) Fourier Transform 15


Windowing

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).

Extracting part of the signal is called windowing. Mathematically, we are multiplying


our long signal by a shorter window function. The naïve window function to use is a
rectangular one. This is equivalent to simply chopping out the part of the signal that
we want to analyse and putting it in the DFT. Doing this can lead to substantial errors
in the resulting spectrum, however. The plot below illustrates the effects of
rectangular windowing for a sine wave at 10 Hz. The peak in the frequency spectrum
is not as sharp as it should be (in theory a delta function) and there seems to be a lot
of energy present at a range of other frequencies. This sort of spectral error is called
smearing and it is important to minimise it.

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

DTAA notes (WJD) Fourier Transform 16


and it looks like this:

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:

DTAA notes (WJD) Fourier Transform 17


1

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.)

Tutorial Questions on the Fourier Transform

1. 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) =  f o tr≥ 0


 −2 t
e
0 f o tr< 0

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.

DTAA notes (WJD) Fourier Transform 18


3. Consider the following real frequency spectrum:
 1, − ω 0 ≤ ω ≤ ω 0 
X (ω ) = 0, − ∞ < ω < −ω 0 
0, ω 0 < ω < ∞ 
Sketch this function and then show that its inverse Fourier Transform is given by
ω
x(t ) = 0 sinc (ω 0 t )
π
Sketch the time signal and reflect on the beautiful symmetry of this case and that
of the rectangular pulse examined earlier!

4. a) Imagine a delta function spike in the frequency domain:


Ξ (ω ) = δ (ω − ω 0 )
Sketch this frequency spectrum. Now use the sifting property of the delta
function to show that the inverse Fourier Transform of X(ω ) is
e jω 0 t
x (t ) =

b) Noting that a cosine is the sum of two complex exponentials,


e jω 0t + e − jω 0t
cos( ω 0 t ) = ,
2
show that the Fourier Transform of y (t ) = cos( ω 0 t ) is given by
Ψ(ω ) = π [δ (ω − ω 0 ) + δ (ω + ω 0 )]
and sketch the frequency spectrum of this cosine. Reflect on the symmetry of
this case with that of question 2.

DTAA notes (WJD) Fourier Transform 19

Vous aimerez peut-être aussi