Beruflich Dokumente
Kultur Dokumente
Lesson #22: Fast Fourier Transform (FFT) Lesson #23: Applications of DFT/FFT
Lesson #24: Using of DFT/FFT
FT of CT periodic signals
x(t )
k
ak e
jk
0t
; ak
1 x(t )e TT
jk
0t
dt;
2 T
FT of CT aperiodic signals
FT of DT aperiodic signals
Recapitulation
Can guess?
x(t )
k
ak e
jk
0t
; ak
1 x(t )e TT
jk
0t
dt
2 T
x[n]
k N
ak e
jk
0n
; ak
1 N
x[n]e
n N
jk
0n
2 N
jk
0n
jk
2 n N
j( k N )
2 n N
j( k N )
0n
[n kN ]
. . . -2N
-N
N
N 1
2N . . . . .
p[n]
k 0
ak e
jk
2 n N
ak
1N1 p[n ]e Nn 0
jk 2 n / N
1 N
x(t)
k
a ke
jk
0t
X( ) 2
k
ak (
x[n ]
X( ) 2
k
ak (
. . . -2N
-N
2N . . . . . . . .
P( ) 2
k
ak
2/N
k
2/N
2 N
2 k N
Height = 2/N
Spacing = 2/N
2/N
2/N
2/N
. . . -4/N
-2/N
2/N
4/N . . . .
N-1
x0 [n]
x[n] 0
0 n
N 1
otherwise
x0 [n]
otherwise
x[n]
k
x0 [n kN ]
k
x0 [n]
[n kN ] x0 [n]
k
[n kN ]
X 0 ( ) P( )
X( )
X 0 ( ) P( )
X( )
X( )
2 X0( ) N 2 N
(
k
2 k ) N 2 k ) N
2 X 0 (k ) ( N
Inverse DTFT
DFT 1 2 1 N
1
X( ) 2 N
x[n ]
1 2
X ( )e j n d
0
2 X 0 (k ) ( N
2
2 k ) e j nd N 1 N
N 1 j 2 X 0 (k )e N 0 k2 n N
2 X 0 (k ) ( N 0
2 k )e j n d N
f (t ) (t t0 )dt
a
f (t0 ) a 0
t0
elsewhere
Summary
Start with x0(n) one period of x(n), with zero everywhere else Step 2:
Find the DTFT X0() of the signal x0[n] above Step 3: Find X0() at N equally spacing frequency points X0(k2/N)
2 N
2 X 0 (k ) ( N
2 k ) N
0
3
2
j n
X0( )
n 0
x0 (n)e
1 e
2e
j3
k = 0 X0(0) = 4;
k = 2 X0(2) = -2;
k = 1 X0(1) = 1+j
k = 3 X0(3) = 1-j
Example (cont)
Example (cont)
24 48
f [Hz]
Sampled signal FT magnitude = copies of unsampled signal FT magnitude; each copy is centered at k40(Hz) or k80(rad/s) fs = 40Hz
fs = 40Hz
8Hz
-64 -56
-24 -16
16 24
40
56 64
f[Hz]
-128 [rad/s]
-48 -32
32 48
80
112
The unit circle represents the scale of frequency range for a signal sampled at 40Hz the reconstructed signal looks like 16Hz.
16 20 24 0 16 24 40 56 64
8Hz
f[Hz]
32 48
80
112
[rad/s]
d) Consider DT signal that is obtained by the sampling x(t) at a sampling frequency of 40 Hz is x(n). Is x(n) a periodic signal? If yes, what is its period? The unsampled signal: x(t) = cos(2.24t)
The sampled signal:
1. DFT and inverse DFT formulas 2. DFT and inverse DFT examples 3. Frequency resolution of the DFT
DFT can be used as a FT approximation that can calculate a finite set of discrete-frequency spectrum values from a finite set of discrete-time samples of an analog signal
Window x(n) is like multiplying the signal by the finite length rectangular window
window
X0( )
n
x0 [n]e
j n n 0
x0 [n]e
j n
DTFT
DTFT
Notation conventions
WN
2 N
1. DFT and inverse DFT formulas 2. DFT and inverse DFT examples 3. Frequency resolution of the DFT
k = 0 X(k) = X(0) = N
k 0 X(k) = 0
X [k ]
n 0
kn x[n ]WN
0,1,..., N 1
X [ 0] XN X [1] X [ N 1] 1
2 WN
XN = WNxN
1
( WN N 1)
1 WNN
1 2 WN ( N 1) ( WN N 1)( N 1)
0,1,..., N 1
The N-point DFT may be expressed in matrix form as:
xN WN X N
* WNWN 1
X [ 0] XN X [1] X [ N 1] 1 W
2 N
1 * WN X N N
1 W
( N 1) N
NI N
I N : identity matrix
x[n] =
[n-1] + 2[n-2] + 3[n-3]
x4
W4
Then X 4
W4 . x 4
1. DFT and inverse DFT formulas 2. DFT and inverse DFT examples 3. Frequency resolution of the DFT
fs N
2 N
The choice of N determines the resolution of the frequency spectrum, or vice-versa To obtain the adequate resolution: 1. Increasing of the duration of data input to the DFT 2. Zero padding, which adds no new information, but effects a better interpolator
Examples of N = 5 and N = 15
Examples of N = 15 and N = 30
DFT properties
x(n)
Finite length
xp(n)
Periodic
DTFT DTFT-1
Xp()
Periodic
X(k)
Finite length
DFT-1
DFT
Xp(k)
Periodic
DFT properties
x(n)
Finite length
xp(n)
Periodic
DTFT DTFT-1
Xp()
Periodic
X(k)
Finite length
DFT-1
DFT
Xp(k)
Periodic
Periodicity
Linearity
DFT
a1 x1[n] a2 x2 [n]
a1 X 1[k ] a2 X 2 [k ]
Proof:
Infer from the definition formula of DFT
x[n m]
Proof:
W X[k]
km
x[n m] 2 k : N e
j m
j m
X( )
X( )
jk
2 m N
X [k ] W km X [k ]
x(n)
Circular
xp(n)
time
shift
xp(n+2)
x(n+2)
6. Parsevals theorem
x[n]W
Proof:
ln
DFT
X [k l ]
X 1[k ]. X 2 [k ]
x1[n]
x2 [n]
p 0
x1[ p]x2 [n
p]
0 2
1 3
y(0) = 16
y(1) = 18
Example (cont)
Evaluate the circular convolution, y(n) of 2 signals: x1(n) = [ 1 2 3 4 ]; x2(n) = [ 0 1 2 3 ]
1 1
2 0
3 1
y(2) = 16
y(3) = 10
x1(n)
x2(n)
DFT DFT
X1(k)
IDFT X2(k) y(n)
X2(k) = [ 6, -2+j2, -2, -2-j2 ]; Y(k) = X1(k).X2(k) = [ 60, -j8, 4, j8 ] y(n) = [ 16, 18, 16, 10 ]
6. Parsevals theorem
Multiplication
DFT
x1[n]. x2 [n]
1 X 1[ k ] N
X 2 [k ]
1 N
N 1
X 1 [l ] X 2 [ k l ]
l 0
6. Parsevals theorem
Parsevals theorem
The general form:
N 1
x[n] y * [n]
n 0
1 N
N 1
X [k ]Y * [k ]
k 0
Special case:
N 1
| x[n] |
n 0
1 N
N 1
| X [k ] |
k 0
N 1
| x[n ] |2
n 0
12
2
22 1 2 (7 4
32 12 2
2
15 1
2
1 N
N 1
| X [k ] |
k 0
1)
60 15 4
b. The Z-transform
c. The Fourier series d. The discrete Fourier transform
b. The Z-transform
c. The Fourier series d. The discrete Fourier transform
X[k ]
n 0
x[n ]W
nk N
0 k
N 1 N 1
x[n ]
0 n
WN
2 N
Using some "tricks" and choosing the appropriate N value, the DFT can be implemented in a very computationally efficient way this is the Fast Fourier Transform (FFT) - which is the basis of lots of contemporary DSP hardware
then split each of these into two of length N/4, etc., until we have N/2 subsequences of length 2
Cooley and Tukey (1965):
2
FFT (cont)
Some properties of
W
*
nk N
can be exploited
W W
k ( N n) N kn N
W
N
kn N
k (n N )
(k N )n N
, periodicit y in n and k
W W
W W
N kn N 2
kn
nN 2 N
W e
N
kn
jn
W , W
N
kn
if n even , if n odd
kn N
FFT
N
points N
4 8 16 32 64
in direct DFT
16
in FFT
4
factor
4.0
64
256 1,024
12
32 80
5.3
8.0 12.8
4,096
16,384 65,536 262,144 1,048,576
192
448 1,024 2,304 5,120
21.3
36.6 64.0 113.8 204.8
128
256 512
1024
X [k ]
neven
x[n]W kn
nodd
k N
x[n]W kn
0,1,..., N 1
X(k) G(k)
H(k), k
DIT-FFT (cont)
N 2
N 2
X [k ]
m 0
N 2
x[2m]W 2 mk
m 0
1
x[2m 1]W k (2 m
N 2
1)
=
m 0
x[2m](W 2 ) mk W k
m 0
x[2m 1](W 2 ) mk
Note:
N 2
2 N
e
mk N /2
j2 / N 2
e
1
j 2 /( N / 2 )
WN / 2
G(k )
X (k )
m 0
g[m]W
k N
N 2
h[m]W
m 0
mk N /2
k N
H (k )
DIT-FFT of length N = 8
X[k]8
0 8
G[k]4
W H[k]4
X[4] G[0] W H[0] X[5] G[1] W H[1] X[6] G[2] W H[2] X[7] G[3] W87 H[3]
6 8 5 8 4 8
k 8
X[0] G[0] W H[0] X[1] G[1] W H[1] X[2] G[2] W H[2] X[3] G[3] W83H[3]
2 8 1 8
DFT N=4
DFT N=4
DIT-FFT of length N = 4
X [k ]4
x[0]
X [0] G[0] W40 H [0]
G[k ]2 W H [k ]2
W0
k 4
x[2]
x[1]
x[3]
DFT N=2
W2
W3
DIT-FFT of length N = 2
1
X [k ]
n 0
2 2
X [0] X [1]
Butterfly diagram
# multiplications are reduced: 22 = 4 0; just 2 additions!!!
x[0]
X[0]
x[1]
-1
X[1]
Example of
8-point FFT
DFT N=4
DFT N=4
G[0]
Example
DFT N = 2
W0 W2
G[1]
G[2] G[3] H[0]
W
0
of
DFT N = 2
W4
W6
8-point
FFT (cont)
W0
DFT N = 2
W0 W2
H[1] H[2]
W4
DFT N = 2
H[3]
W6
Second step: split each of 4-point DFT into two 2-point DFTs
Example
W0 W2
W0 W1
of 8-point
FFT (cont)
W0
W4
W6
W2 W3
W0
W0 W2
W4 W6
W4 W5
W6
W7
Third step: combine all signal flow graphs of step 1 and step 2 There are 3 = log28 stages; 4 butterfly diagrams in each stage
Butterfly diagram
Wr
-1 Wr+N/2
Wr+N/2 = -Wr
In-place computation
a A
Wr
-1
Each butterfly takes (a,b) to produce (A,B) no need to save (a,b) can store (A,B) in the same locations as (a,b) We need 2N store registers to store the results at each stage and these registers are also used throughout the computation of the N-point DFT The order of the input: bit-reversed order The order of the output: natural order
X (k )
n 0
x(n)W
kn N
kn x(n)WN , k n ( N / 2)
0,1,..., N 1
x(n)W
n ( N / 2)
kn N n 0
x n
kN 2 N
( N / 2) 1
N k n WN 2
N 2
k N
N 2
( N / 2) 1
x n
n 0
N kn WN 2
Since:
j ( k 2 / N )( N / 2 )
( 1)
then
X (k )
n 0
0,1,..., N 1
DIF-FFT (cont)
X ( 2k )
n 0
x ( n ) x ( n N / 2) W
( N / 2) 1
2 kn N
,k
N 0,1,..., 2 ,k
1 1
X (2k 1)
n 0
x ( n ) x ( n N / 2) W
2 N
( 2 k 1) n N
N 0,1,..., 2
Since: then,
2 N /2
( N / 2) 1
X ( 2k )
n 0
x ( n ) x ( n N / 2) W
( N / 2) 1
kn N /2
,k
n N
N 0,1,..., 2
kn N /2
1 1
X (2k 1)
n 0
x ( n ) x ( n N / 2) W W
,k
N 0,1,..., 2
DIF-FFT butterfly
x[n]
x[n] + x[n+N/2]
x[n+N/2] -1 WNn
(x[n] - x[n+N/2])WNn
DIF-FFT of length N = 4
x[0] x[0] + x[2]
X[0]
x[1]
X[2]
-1
x[2]
-1
X[1]
-1
x[3] W41 X[3]
(x[1] - x[3])W41
-1
Step 2. Determine the sampling frequency required to sample the analog signal so as to avoid aliasing s 2M
Step 3. Accumulate N samples of the analog signal over N.T seconds (T = 2/s) Step 4. Calculate DFT directly or using FFT algorithm
Example
1
f(t) = rect[(t-1)/2]
f[n]
F() = 2sinc()e-j
0.5
Ts = 1s
0 0.5 1 1.5 n 2 2.5 3
magnitude
2 1 0
2 omega
Example
1
f(t) = rect[(t-1)/2]
f[n]
F() = 2sinc()e-j
0.5
Ts = 0.2s
0 5 n 10 15
magnitude
2 1 0
10
15 omega
20
25
30
Example
1
f(t) = rect[(t-1)/2]
F() = 2sinc()e-j
f[n]
0.5
Ts = 0.1s
0 5 10 15 n 20 25 30 35
magnitude
%Error of sample 1 = 5%
2 1 0
10
20
30 40 omega
50
60
70
Windowing
Source of error: truncation or windowing of the periodic extension of the DT sequence implied in the DFT development Windowing = multiplying the periodic extension of x[n] by a rectangular function with duration N.T DFT involves a convolution
2. Linear convolution
y[n]
x1[n] * x2 [n]
p
x1[ p]x2 [n
p]
N1: the non-zero length of x1(n); N2: the non-zero length of x2(n); Ny = N1 + N2 -1
y[n]
x1[n]
x2 [n]
p 0
x1[ p]x2 [n
p]
by zero padding both sequences so that they both consists of N1+N2-1 samples.
x1(n)
N1 samples
Zero padding
(N2-1) zeros
x2(n)
N2 samples
Zero padding
(N1-1) zeros
x1(n) = [ 1 2 3 4 0 0 0 ]; x2(n) = [ 0 1 2 3 0 0 0 ] X1(k) = [ 10, -2.0245-j6.2240, 0.3460+j2.4791, 0.1784j2.4220, 0.1784+j2.4220, 0.3460-j2.4791, -2.0245-j6.2240 ];
X2(k) = [ 6, -2.5245-j4.0333, -0.1540+j2.2383, -0.3216j1.7950, -0.3216+j1.7950, -0.1540-j2.2383, -2.5245+j4.0333]; Y(k) = [ 60, -19.9928+j23.8775, -5.6024+j0.3927, -5.8342j0.8644, -4.4049+j0.4585, -5.6024-j0.3927, -19.9928 +j23.8775 ] IDFT{Y(k)} = y(n) = [ 0 1 4 10 16 17 12 ]
Filtering
The response, y(n) of a filter with the impulse response, h(n) to an input, x(n) can be calculated by using the DFT Limitations: All sample values of the signal must be accumulated before the process begins
Great memory Long time delay
Divide long input signal, x(n) into non-overlapped blocks, xb(n) of appropriate length for FFT calculation.
Convolve each block xb(n) and h(n) to get the output,
yb(n)
h(n)
x(n)
x1(n)
x2(n)
Example (cont)
y0(n)
y1(n)
y2(n)
HW
Prob.1 12.10 Prob. 2 12.11 Prob. 3 12.12 Prob. 4 12.15 Prob. 5 12.18 Prob. 6 12.22 Prob. 7 12.24 Prob. 8 12.30
HW
Prob.9
[n 1] 2 [n 2] 3 [n 3] 4 [n 4] [n 1] [n ]
HW
Prob.10
x[n] y * [n]
n 0
1 N
N 1
X [k ]Y * [k ]
k 0
2. Convolution
3. Filtering 4. Correlation 5. ESD estimation
Windowing
1
f[n]
0.5
10
20
30 n
40
50
60
70
magnitude
2 1 0
10
15 20 omega
25
30
35