The Discrete Fourier Transform
The Discrete Fourier Transform
Transform
The spectrum of a sampled function is given by
X s () X (e ) j
x[n]e
n
jnT
x[n]e
n
j n
N 1
x[n]e j n
.
n 0
k
2p k 0, 1, ..., N 1.
N
k
2p k 0, 1, 2, 3.
4
0, p2 ,p , 32p .
p2
p 0
Re
2p
32p
When we insert
k
2p .
N
into
N 1
~ j
X (e ) x[n]e j n
n 0
we get
N 1
~ j
x[n]e
j 2p nk
X [ k ] X (e ) N
.
2p k
N n 0
N 1
X [k ] DFTx[n] x[n]e
j 2p nk
N
.
n 0
Example: Find the discrete Fourier transform of
x[n]=d[n], for N=4.
3
X [k ] DFTd [n] d [n]e
j 2p nk
4
n 0
1e
j 2p nk
4
n 0
j 2p 0k
e 4
1.
3
X [k ] DFT1 1e
j 2p nk
4
n 0
1e 1e 1e 1e
j 2p 0k
4
j 2p 14k j 2p 2k
4
j 2p 3k
4
j 2p k j 2p 2k j 2p 3k
1 e 4
e 4
e 4
.
j 2p 0 j 2p 2 40 j 2p 3 40
X (0) 1 e e 4
e
1 1 1 1 4.
nk 3,7 j j 2p nk
e 4
nk 2, 6
1
Re
1
nk 0
nk 4, 8
nk 1,5,9 j
j 2p 1 j 2p 2 41 j 2p 3 41
X (1) 1 e 4
e e
1 j (1) j 0.
j 2p 2 j 2p 2 42 j 2p 3 42
X ( 2) 1 e 4
e e
1 (1) 1 (1) 0.
j 2p 3 j 2p 2 43 j 2p 3 43
X (3) 1 e 4
e e
1 j (1) j 0.
The previous example suggests that the discrete
Fourier transform can be calculated using a matrix
equation:
j 2p 0 j 2p 2 40 j 2p 3 40
X (0) 1 e 4
e e .
j 2p 1 j 2p 2 41 j 2p 3 41
X (1) 1 e 4
e e .
j 2p 2 j 2p 2 42 j 2p 3 42
X (2) 1 e 4
e e .
j 2p 3 j 2p 2 43 j 2p 3 43
X (3) 1 e 4
e e .
X [0] 1 1 1 1 x[0]
X [1] 1 j 1 j x[1]
.
X [2] 1 1 1 1 x[2]
X [3] 1 j 1 j x[3]
For the previous examples we have
x[n]=d[n]
In general we have
k
.
N s
Example: Suppose we sample a 2 kHz sinewave at
8000 samples/second. If we perform a 1024-point
DFT, where are the spikes in the transform?
Solution:
k 2
k 256.
1024 8
There will also be a spike at k=1024-256=768.
We can perform discrete Fourier transformations in
MATLAB using the function fft(). In MATLAB, as in
other software packages, the discrete Fourier
transform is implemented using an algorithm called
a fast Fourier transform. The previous examples
were done using MATLAB as will be shown on the
following slides.
x[n] = d[n]
>> x = [1 0 0 0];
>> X = fft(x)
X =
1 1 1 1
x[n] = 1
>> x = [1 1 1 1];
>> X = fft(x)
X =
4 0 0 0
x[n] = {1 –1 1 –1}
>> x = [1 -1 1 -1];
>> X = fft(x)
X =
0 0 4 0
x is a 2 kHz sinewave
>> n = 0:1023;
>> t = n/8000;
>> x = sin(2000*2*pi*t);
>> X = fft(x);
>> plot(n,abs(X));
Discrete Fourier Transform of Sampled Sinewave
600
500
400
X(k)
300
200
100
0
0 200 400 600 800 1000 1200
k
Example: Suppose we sample a sinewave at 16000
samples/second. After performing a 2048-point
DFT, we have frequency spikes at k=128 and k =
1920. Find the frequency of the sinewave.
Solution:
128 f
f 1000 Hz.
2048 16000
Example: Suppose we sample the following signal
at 4000 samples/sec:
k 250
k 32.
512 4000
We also get (alias) spikes at k = 448 and k = 480.
The Fast Fourier Transform
An N-point DFT takes N2 complex multiplications
and N2 complex additions. For large values of N, the
number of computations becomes very large. A
number of computationally-efficient algorithms have
been developed called fast Fourier transforms,
whose number of computations is far less than N2.
X [ 0]
W W 0 0
W W x[0]
0 0
X [1] 0 1 2 3
W W W W x[1]
.
X [2] W 0 W 2 6
W W x[2]
4
0 9
W W W W x[3]
3 6
X [ 3]
Because of the periodicity of Wnk, we have
X [ 0]
W W 0 0
W W x[0]
0 0
X [1] 0 1 2 3
W W W W x[1]
.
X [2] W 0 W 2 2
W W x[2]
0
0 1
W W W W x[3]
3 2
X [ 3]
Now, suppose we rearrange the order of the x[n]
(time-domain) values:
X [ 0] W 0
W W W x[0]
0 0 0
X [1] 0 2 1 3
W W W W x[2]
.
X [2] W 0 2
W W W x[1]
0 2
0 1
X [3] W W W W x[3]
2 3
This reordering lends itself to a repartitioning of the
matrices:
X [ 0] W 0
W W W x[0]
0 0 0
X [1] 0 2 1 3
W W W W x[2]
.
X [2] W 0 2
W W W x[1]
0 2
0 1
X [3] W W W W x[3]
2 3
Adopting further notation for the partitioned matrix,
we have
where
W 0 W 0
W11 0 2
WN / 2 ,
W W
W 2 W 2
W22 3 1 .
W W
W22 [W 2 , W 3 ]WN / 2 .
Xfirst half WN/ 2 xeven [1,W 1 ]WN/ 2 xodd
X W x 2 3 ,
second half N/ 2 even [W ,W ]WN / 2 xodd
Xfirst half
xeven N/2 +
[1, W1]
Xsecond half
xodd N/2 +
[W2, W3]
Further detail can be given to the block diagram:
+ X0
xeven N/2
+ X1
W1
+ X2
xodd N/2 W2
+ X3
W3
Finally,
x0 + + X0
x2 + + X1
W2
W1
x1 + + X2
W2
x3 + + X3
W2 W3
The resultant algorithm is called a [decimation in
time, radix-2] fast Fourier transform (FFT) and
uses fewer complex multiplications than a
conventional discrete Fourier transform (DFT). The
[radix-2] FFT algorithm consists of a number of
operations that look like this:
+
a
+
b
X [0] W 0 W 0 W 0 W 0 x[0]
X [2] 0 2 0 2
W W W W x[1]
.
X [1] W 0 W 1 3
W W x[2]
2
0 1
W W x[3]
3 2
X [3] W W
X [0] W 0 W 0 W 0 W 0 x[0]
X [2] 0 2 0 2
W W W W x[1]
,
X [1] W 0 W 1 3
W W x[2]
2
0 1
W W x[3]
3 2
X [3] W W
Xeven WN / 2 WN / 2 x1
X W [1,W 1 ] W [W 2 ,W 3 ] x .
odd N / 2 N /2 2
x1 + N/2 X0,2
[1, W1]
x2 + N/2 X1,3
[W2, W3]
x0 + + X0
x1 + + X2
W2
W1
x2 + + X1
W2
x3 + + X3
W3 W2