Professional Documents
Culture Documents
Getting The Result of Linear Convolution Using DFT
Getting The Result of Linear Convolution Using DFT
ilolu
ilolu
MATLAB Example
x = [1 2 3];
y = [-1 2 1 2];
z = conv(x,y);
z = -1
2 10
X = fft(x,6)
X = 6 0.5-4.3i
-1.5 + 0.9i
-1.5-0.9i
0.5+4.3i
Y = fft(y,6)
Y=4
-2.5 - 2.6i
-0.5 - 0.9i
-4
-0.5 +0. 9i
-2.5 + 2.6i
-12.5 +9.5i
1.5 + 0. 9i
-8
1.5 -0. 9i
-12.5 - 9.5i
Z=X.*Y
Z =24
z_=ifft(Z)
z = -1
2 10
X = fft(x,5)
X =6
-0.8 -3.7i
0.3+1.7i
0.3-1.7i
-0.8+3. 7i
Y =4
-2.8 - 1.3i
-1.7 - 2.1i
-1.7 + 2.1i
-2.8 + 1.3i
Z =24
-2.5 + 11.4i
3.0 - 3.5i
3.0 + 3.5i
-2.5 - 11.4i
Y = fft(y,5)
Z = X.*Y
z_= ifft(Z)
ilolu
z_ =
2 10
DTFT
xn
X e j
length N X
Let
X k X e j
2
N
k 0,1,..., N 1
[] = ? ? ?
(-point IDFT of [])
ilolu
[] = {
1
=0 [ ]
= 0,1, , 1
. .
[] = ( [] )
=0
=0
1
()
= [] (
=0
=
= []
= ( [] [ ])
=
= [ ]
=
Therefore
xn mN
xn m
0
ilolu
n 0,1,..., N 1
o.w.
Ex: = 6, = 4
x n
xn m4
xn
5
j
1 e j 6 e j 3 e j 3 e j 3
sin 3
2
X e
j
j
j
1 e j
2
2
2
sin
e
e e
2
j
For N = 4
X 0 6 X 1 1 j
X 2 0
X 3 1 j
and
x4 n :
ilolu
0 0 2 2 11 0 0
n 0
xne
X e
jn
n 0
xne
jn
X k X e j
2
5
xnW
kn
5
W5k 0
x0 x5
W5k 1
W5k 2
x1 x6W5k
x2 x7W5k 2
x3W5k 3
x4W5k 4
x0 x0 x5
x1 x1 x6
x2 x2 x7
x3 x3
x4 x4
ilolu
DFS
Let x1 n and x2 n be periodic with common period N.
x3 n x1 n x2 n
1 N 1
X 3 k X 1 l X 2 k l
N l 0
DFS
DFT
Let x n and
x2 n
point DFTs,
N max N1 , N2 .
x3 n x1 n x2 n
ilolu
X1 k
and
1 N 1
X 3 k X 1 l X 2 k l N
N l 0
N -point DFT
X 2 k
their N-
k 0,1,..., N 1
Multiply the DFTs of input and impulse response and compute the IDFT
ilolu
BLOCK PROCESSING
ilolu
10
Two Methods
Overlap-Add
DFT length:
L+P-1 point
DFT length:
L point
Overlap-Save
ilolu
11
OVERLAP-ADD METHOD
Lets start with a linear convolution example
hn: ..., 0, 0, 1 , 2, 3, 0, 0,...
3-point sequence (P = 3)
n 0
n 0
Linear convolution:
6+3-1 = 8 points
1 2 3
6
2
4
2 4 6
1 2 3
1 2 3
3 1
1 1
1 7 1 3
n 0
yn : ..., 0, 0, 1 , 1, 3, 1, 1, 7, 1, 3 , 0, 0...
n 0
ilolu
12
By Overlap-add:
hn: ..., 0, 0, 1 , 2, 3, 0, 0,...
3-point sequence (P = 3)
n 0
n 0
xn : ..., 0, 0, 1, 1, 2, 2, 1, 1, 0, 0 ,...
x1
x2
DFT of h
X1 and X2
Compute
y1 = IDFT{ H X1 }
y1 : ..., 0, 0, 1, 1, 3, 1, 6, 0, 0 ,...
y2 = IDFT{ H X2 }
y2 : ..., 0, 0, 0, 0, 2, 5, 7, 1, 3, 0, 0 ,...
and
1
6
2 5 7 1 3
1 1 3 1 1 7 1 3
n 0
ilolu
13
r th
block is
x n rL
xr n
0nL
o.w.
For the
r th
so that
x n xr n rL
r 0
H k
yr n
y0 n , y1 n , y2 n , ...
ilolu
14
input segments
n0
L samples
L P 1 samples
output segments
ilolu
15
OVERLAP-SAVE METHOD
Ex:
hn: ..., 0, 0, 1 , 2, 3, 0, 0,...
3-point sequence (P = 3)
n 0
n 0
Because of the two incorrect samples at each output block, the first segment is
choosen to start at = ( 1) = 2
x1
x2
x1
16
1 , 2 , 3 , 4 , 5 , . ..
DFT of
Compute
1 = { 1 }
y1 : ..., 0, 0, 1, 3, 1, 1, 0, 0 ,...
2 = { 2 }
y2 : ..., 0, 0, 3, 5, 3, 1, 0, 0 ,...
3 = { 3 }
y3 : ..., 0, 0, 1, 5, 1, 7, 0, 0 ,...
4 = { 4 }
y4 : ..., 0, 0, 1, 1, 1, 3, 0, 0 ,...
5 = { 5 }
y5 : ..., 0, 0, 0, 0, 0, 0, 0, 0 ,...
saved
1
3
1
5
3
1
3
1
5
1
1
1
1
7
1
7
1
1
3
3
n 0
n 0
ilolu
17
<+1
( )
L samples
i.e,
x0 n xn P 1
0 n L 1
X 0 k
H k
Compute
y 0 n L-point IDFT of X 0 k H k .
Discard the first (P-1) samples to get the first ouput segment
y n
y0 n 0
P 1 n L 1
o.w.
n 0,1,..., L P 1 1
xL P P 1 1, ..., x2L 2 P 1
L samples
i.e.
ilolu
xL 2P 2, ...,x2L 2P 1
18
n0
L samples
P1 zeros
P1 samples
input segments
P -1 samples discarded
output segments
ilolu
19
( ) = ( )( )
[] = {( )}
= [ ] [ ]
ilolu
20
where
[] = (( )( ))|
2
=
= 0,1, , 1
ilolu
21
[ ]
[] =
ilolu
= 0,1, , 1
. .
22
Compute
[ ] = [ ] [ ]
[ ]
[ ] [ ] =
= 0,1, , 1
. .
or as
[] [] = {[][]}
ilolu
23
Ex:
[] = [ 0 0
2 0 0 ]
=0
[] = [ 0 0 2
1 1 0 0 ]
=0
c) Let
[] = ( )|
[] = ( )|
2
= 2
= 0,1
2
2
= 0,1
ilolu
24
a)
[ ] = [ ] 5 [ ]
4
= [] [(( ))5 ]
= 0,1,2,3,4
= 0,1,2,3,4
=0
2
1 1 0 0
0 4 2 2 0
2 3 3 2 0
Therefore
[] = [ 0 0 2
3 3 2 0 0 ]
=0
ilolu
25
b)
[ ] = [ ] 3 [ ]
2
= [] [(( ))3 ]
= 0,1,2
= 0,1,2
=0
2
1 1
2 4 2
0 3 3
Therefore
[] = [ 0 0 3
3 0 0 ]
=0
or
[ ] = [ ] 3 [ ]
[ 3]
=
= 0,1,2
{ 0
. .
n 0 n 1 n 2
ilolu
2 3 3
2
0
2
2 3 3 2
3
26
c)
1
2
1
[] [] 2
2
[ ] =
= 0,1
=0
. .
[ 2]
=
= 0,1
=0
. .
where
[ ] = [ ] [ ]
(linear conv.)
Therefore
n 0 n 1
2 3
3
1
2
3
[] = [ 0 0
3 2
2 3 3 2
1 3 0 0 ]
=0
ilolu
27