Beruflich Dokumente
Kultur Dokumente
8
Copyright © 2001, S. K. Mitra
DTFT Computation Using
MATLAB
• The function freqz can be used to
compute the values of the DTFT of a
sequence, described as a rational function in
in the form of
− jω − j ωM
p + p e + .... + p e
X ( e jω ) = 0 1 M
d 0 + d1e − jω + .... + d N e − jωN
at a prescribed set of discrete frequency
points ω = ωl
9
Copyright © 2001, S. K. Mitra
DTFT Computation Using
MATLAB
• For example, the statement
H = freqz(num,den,w)
returns the frequency response values as a
vector H of a DTFT defined in terms of the
vectors num and den containing the
coefficients { pi } and {di } , respectively at a
prescribed set of frequencies between 0 and
2π given by the vector w
10
Copyright © 2001, S. K. Mitra
DTFT Computation Using
MATLAB
• There are several other forms of the
function freqz
• The Program 3_1 in the text can be used to
compute the values of the DTFT of a real
sequence
• It computes the real and imaginary parts,
and the magnitude and phase of the DTFT
11
Copyright © 2001, S. K. Mitra
DTFT Computation Using
MATLAB
• Example - Plots of the real and imaginary
parts, and the magnitude and phase of the
DTFT − jω − j 2ω
0.008 − 0.033 e + 0.05 e
− j 3ω − j 4ω
jω − 0.033 e + 0.008 e
X (e ) =
1 + 2.37 e − jω + 2.7 e − j 2ω
+ 1.6 e − j 3ω + 0.41e − j 4ω
12
are shown on the next slide
Copyright © 2001, S. K. Mitra
DTFT Computation Using
MATLAB
Real part Real part
1 1
0.5 0.5
Amplitude
Amplitude
0 0
-0.5 -0.5
-1 -1
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
ω/π ω/π
Magnitude Spectrum Phase Spectrum
1 4
0.8
2
Phase, radians
Magnitude
0.6
0
0.4
-2
0.2
13 0
0 0.2 0.4 0.6 0.8 1
-4
0 0.2 0.4 0.6 0.8 1
ω/π Copyright
ω/π© 2001, S. K. Mitra
DTFT Computation Using
MATLAB
• Note: The phase spectrum displays a
discontinuity of 2π at ω = 0.72
• This discontinuity can be removed using the
function unwrap as indicated below
Unwrapped Phase Spectrum
0
-1
-2
Phase, radians
-3
-4
-5
-6
-7
0 0.2 0.4 0.6 0.8 1
14 ω/π
Copyright © 2001, S. K. Mitra
Linear Convolution Using
DTFT
• An important property of the DTFT is given
by the convolution theorem in Table 3.2
• It states that if y[n] = x[n] * h[n], then the
jω
DTFT Y (e ) of y[n] is given by
jω jω jω
Y (e ) = X (e ) H (e )
• An implication of this result is that the
linear convolution y[n] of the sequences
x[n] and h[n] can be performed as follows:
15
Copyright © 2001, S. K. Mitra
Linear Convolution Using
DTFT
jω jω
• 1) Compute the DTFTs X (e ) and H (e )
of the sequences x[n] and h[n], respectively
jω jω jω
• 2) Form the DTFT Y (e ) = X (e ) H (e )
jω
• 3) Compute the IDFT y[n] of Y ( e )
X ( e jω )
x[n] DTFT Y ( e jω )
× IDTFT y[n]
h[n] DTFT
H ( e jω )
16
Copyright © 2001, S. K. Mitra
Discrete Fourier Transform
• Definition - The simplest relation between a
length-N sequence x[n], defined for
jω
0 ≤ n ≤ N − 1 , and its DTFT X (e ) is
obtained by uniformly sampling X (e jω ) on
the ω-axis between 0 ≤ ω ≤ 2π at ωk = 2π k / N ,
0 ≤ k ≤ N −1
• From the definition of the DTFT we thus have
N −1
X [ k ] = X ( e jω ) = ∑ x[n] e − j 2 π k / N ,
ω= 2 π k / N n =0
17 0 ≤ k ≤ N −1
Copyright © 2001, S. K. Mitra
Discrete Fourier Transform
• Note: X[k] is also a length-N sequence in
the frequency domain
• The sequence X[k] is called the discrete
Fourier transform (DFT) of the sequence
x[n]
• Using the notation WN = e − j 2π / N the
DFT is usually expressed as:
N −1
X [k ] = ∑ kn
x[n]WN , 0 ≤ k ≤ N −1
18 n =0
Copyright © 2001, S. K. Mitra
Discrete Fourier Transform
• The inverse discrete Fourier transform
(IDFT) is given by
1 N −1 − kn
x[n] = ∑ X [ k ]WN , 0 ≤ n ≤ N −1
N k =0
(
1 − rN
= WN + WN
2
)rN
24
Copyright © 2001, S. K. Mitra
Discrete Fourier Transform
• The N-point DFT of g[n] is thus given by
N −1
G[k ] = ∑ g [n]WNkn
n =0
1 N −1 −( r − k ) n N −1 ( r + k ) n
= ∑ WN + ∑ WN ,
2 n =0 n =0
0 ≤ k ≤ N −1
25
Copyright © 2001, S. K. Mitra
Discrete Fourier Transform
• Making use of the identity
N −1 N , for k − l = rN , r an integer
WN−( k −l )n
∑ = 0, otherwise
n =0
we get
N / 2, for k = r
G[k ] = N / 2, for k = N − r
0, otherwise
0 ≤ k ≤ N −1
26
Copyright © 2001, S. K. Mitra
Matrix Relations
• The DFT samples defined by
N −1
X [k ] = ∑ kn
x[n]WN , 0 ≤ k ≤ N −1
n =0
can be expressed in matrix form as
X = DN x
where
X = [ X [0] X [1] ..... X [ N − 1]] T
1 1 1 L 1
1 1 2 ( N −1)
WN WN L WN
2( N −1)
D N = 1 WN2 WN4 L WN
M M M O M
1 W ( N −1) W 2( N −1) ( N −1)2
L WN
N N
28
Copyright © 2001, S. K. Mitra
Matrix Relations
• Likewise, the IDFT relation given by
N −1
x[n] = ∑ X [k ]WN− kn , 0 ≤ n ≤ N − 1
k =0
29
Copyright © 2001, S. K. Mitra
Matrix Relations
where
1 1 1 L 1
1 −1 −2 −( N −1)
WN WN L WN
−1 − 2( N −1)
D N = 1 WN− 2 WN− 4 L WN
M M M O M
1 W −( N −1) W − 2( N −1) −( N −1)2
L WN
N N
• Note:
−1 1 *
DN = DN
30
N
Copyright © 2001, S. K. Mitra
DFT Computation Using
MATLAB
• The functions to compute the DFT and the
IDFT are fft and ifft
• These functions make use of FFT
algorithms which are computationally
highly efficient compared to the direct
computation
• Programs 3_2 and 3_4 illustrate the use of
these functions
31
Copyright © 2001, S. K. Mitra
DFT Computation Using
MATLAB
• Example - Program 3_4 can be used to
compute the DFT and the DTFT of the
sequence
x[n] = cos(6πn / 16), 0 ≤ n ≤ 15
as shown below
10
0
32 0 0.2 0.4 0.6 0.8 1
Normalized angular frequency Copyright © 2001, S. K. Mitra
DTFT from DFT by
Interpolation
• The N-point DFT X[k] of a length-N
sequence x[n] is simply the frequency
samples of its DTFT X (e jω ) evaluated at N
uniformly spaced frequency points
ω = ωk = 2π k / N , 0 ≤ k ≤ N − 1
• Given the N-point DFT X[k] of a length-N
jω
sequence x[n], its DTFT X (e ) can be
uniquely determined from X[k]
33
Copyright © 2001, S. K. Mitra
DTFT from DFT by
Interpolation
• Thus
N −1
jω − jω n
X (e ) = ∑ x[n] e
n =0
N −1 1 N −1
− k n − jω n
= ∑ ∑ X [k ]WN e
n =0 N k =0
1 N −1 N −1
− j ( ω− 2 π k / N ) n
= ∑ X [k ] ∑ e
N k =0 n =0
34 S
Copyright © 2001, S. K. Mitra
DTFT from DFT by
Interpolation
• To develop a compact expression for the
sum S, let
− j ( ω− 2 πk / N )
r −=1 e
= ∑ r + r −1 = S + r −1
N
n =1
n N N
• Then S = ∑nN=−01r n
• From the above
N −1 n
rS = ∑n =1 r = 1 + ∑n =1 r + r − 1
N n N
N −1 n
= ∑n =1 r + r −1 = S + r −1
N N
35
Copyright © 2001, S. K. Mitra
DTFT from DFT by
Interpolation
• Or, equivalently,
S − rS = (1 − r )S = 1 − r N
• Hence
− j ( ωN − 2 πk )
1− r N
1− e
S= =
1 − r 1 − e − j[ω−( 2 πk / N )]
ωN − 2 π k
sin
= 2 ⋅e − j[( ω− 2 π k / N )][( N −1) / 2]
ωN − 2 π k
sin
36
2N
Copyright © 2001, S. K. Mitra
DTFT from DFT by
Interpolation
• Therefore
jω
X (e )
ωN − 2 π k
−
sin
=
1 N 1
∑ X [k ] 2 ⋅e − j[( ω− 2 π k / N )][( N −1) / 2]
N k =0 ωN − 2 π k
sin
2N
37
Copyright © 2001, S. K. Mitra
Sampling the DTFT
jω
• Consider a sequence x[n] with a DTFT X (e )
jω
• We sample X (e ) at N equally spaced points
ωk = 2π k / N, 0 ≤ k ≤ N − 1 developing the N
jωk
frequency samples { X (e )}
• These N frequency samples can be
considered as an N-point DFT Y[k] whose N-
point IDFT is a length-N sequence y[n]
38
Copyright © 2001, S. K. Mitra
Sampling the DTFT
∞
• Now X (e jω ) = ∑ x[l] e − jωl
l = −∞
jωk j 2π k / N
• Thus Y [k ] = X (e ) = X (e )
∞ ∞
= ∑ x[l] e − j 2 π kl/ N = ∑ x[l]WNkl
l = −∞ l = −∞
• An IDFT of Y[k] yields
1 N −1 −kn
y[n] = ∑ Y [k ]WN
39 N k =0
Copyright © 2001, S. K. Mitra
Sampling the DTFT
1 N −1 ∞
• i.e. y[n] = ∑ ∑ x[l]WNkl WN− k n
N k =0 l = −∞
∞ 1 N −1 − k ( n −l )
= ∑ x[l] ∑ WN
l = −∞ N k =0
• Making use of the identity
1 N −1 − k ( n − r ) 1, for r = n + mN
∑ WN = 0, otherwise
N n =0
40
Copyright © 2001, S. K. Mitra
Sampling the DTFT
we arrive at the desired relation
∞
y[n] = ∑ x[n + mN ], 0 ≤ n ≤ N − 1
m = −∞
• Thus y[n] is obtained from x[n] by adding
an infinite number of shifted replicas of
x[n], with each replica shifted by an integer
multiple of N sampling instants, and
observing the sum only for the interval
0 ≤ n ≤ N −1
41
Copyright © 2001, S. K. Mitra
Sampling the DTFT
• To apply
∞
y[n] = ∑ x[n + mN ], 0 ≤ n ≤ N − 1
m = −∞
to finite-length sequences, we assume that
the samples outside the specified range are
zeros
• Thus if x[n] is a length-M sequence with
M ≤ N , then y[n] = x[n] for 0 ≤ n ≤ N − 1
42
Copyright © 2001, S. K. Mitra
Sampling the DTFT
• If M > N, there is a time-domain aliasing of
samples of x[n] in generating y[n], and x[n]
cannot be recovered from y[n]
• Example - Let {x[n]} = {0 1 2 3 4 5}
↑
44
Copyright © 2001, S. K. Mitra
Numerical Computation of the
DTFT Using the DFT
• A practical approach to the numerical
computation of the DTFT of a finite-length
sequence
jω
• Let X e ) be the DTFT of a length-N
(
sequence x[n]
jω
• We wish to evaluate X (e ) at a dense grid
of frequencies ωk = 2π k / M, 0 ≤ k ≤ M − 1,
where M >> N:
45
Copyright © 2001, S. K. Mitra
Numerical Computation of the
DTFT Using the DFT
N −1 N −1
jωk − jωk n − j 2 π kn/ M
X (e ) = ∑ x[n] e = ∑ x[n] e
n =0 n =0
• Define a new sequence
x[n], 0 ≤ n ≤ N − 1
xe [n] =
0, N ≤ n ≤ M −1
• Then
M −1
jωk
X (e ) = ∑ x[n] e − j 2 π kn/ M
n =0
46
Copyright © 2001, S. K. Mitra
Numerical Computation of the
DTFT Using the DFT
jωk
• Thus X (e ) is essentially an M-point DFT
X e [k ] of the length-M sequence xe [n]
• The DFT X e [k ] can be computed very
efficiently using the FFT algorithm if M is
an integer power of 2
• The function freqz employs this approach
to evaluate the frequency response at a
prescribed set of frequencies of a DTFT
47
expressed as a rational function in e − jω
Copyright © 2001, S. K. Mitra
DFT Properties
• Like the DTFT, the DFT also satisfies a
number of properties that are useful in
signal processing applications
• Some of these properties are essentially
identical to those of the DTFT, while some
others are somewhat different
• A summary of the DFT properties are given
in tables in the following slides
48
Copyright © 2001, S. K. Mitra
Table 3.5: General Properties
of DFT
49
Copyright © 2001, S. K. Mitra
Table 3.6: DFT Properties:
Symmetry Relations
50
x[n] is a complex sequence Copyright © 2001, S. K. Mitra
Table 3.7: DFT Properties:
Symmetry Relations
52
Copyright © 2001, S. K. Mitra
Circular Shift of a Sequence
• If x[n] is such a sequence, then for any
arbitrary integer no , the shifted sequence
x1[n] = x[n − no ]
is no longer defined for the range 0 ≤ n ≤ N − 1
• We thus need to define another type of a
shift that will always keep the shifted
sequence in the range 0 ≤ n ≤ N − 1
53
Copyright © 2001, S. K. Mitra
Circular Shift of a Sequence
• The desired shift, called the circular shift,
is defined using a modulo operation:
xc [n] = x[〈 n − no 〉 N ]
• For no > 0 (right circular shift), the above
equation implies
x[n − no ], for no ≤ n ≤ N − 1
xc [n] =
x[ N − no + n], for 0 ≤ n < no
54
Copyright © 2001, S. K. Mitra
Circular Shift of a Sequence
• Illustration of the concept of a circular shift
x[n] x[ 〈 n − 1〉 6 ] x[ 〈 n − 4〉 6 ]
= x[ 〈 n + 5〉 6 ] = x[ 〈 n + 2〉 6 ]
55
Copyright © 2001, S. K. Mitra
Circular Shift of a Sequence
• As can be seen from the previous figure, a
right circular shift by no is equivalent to a
left circular shift by N − no sample periods
• A circular shift by an integer number no
greater than N is equivalent to a circular
shift by 〈 no 〉 N
56
Copyright © 2001, S. K. Mitra
Circular Convolution
• This operation is analogous to linear
convolution, but with a subtle difference
• Consider two length-N sequences, g[n] and
h[n], respectively
• Their linear convolution results in a length-
( 2 N − 1) sequence yL [n] given by
N −1
y L [n ] = ∑ g[m] h[n − m], 0 ≤ n ≤ 2N − 2
m =0
57
Copyright © 2001, S. K. Mitra
Circular Convolution
• In computing yL [n] we have assumed that
both length-N sequences have been zero-
padded to extend their lengths to 2 N − 1
• The longer form of y L [n] results from the
time-reversal of the sequence h[n] and its
linear shift to the right
• The first nonzero value of y L [n] is
y L [0] = g [0]h[0], and the last nonzero value
is y L [2 N − 2] = g [ N − 1]h[ N − 1]
58
Copyright © 2001, S. K. Mitra
Circular Convolution
• To develop a convolution-like operation
resulting in a length-N sequence yC [n], we
need to define a circular time-reversal, and
then apply a circular time-shift
• Resulting operation, called a circular
convolution, is defined by
N −1
yC [n] = ∑ g[m] h[〈 n − m〉 N ], 0 ≤ n ≤ N − 1
m =0
59
Copyright © 2001, S. K. Mitra
Circular Convolution
• Since the operation defined involves two
length-N sequences, it is often referred to as
an N-point circular convolution, denoted as
y[n] = g[n] N h[n]
• The circular convolution is commutative,
i.e.
g[n] N h[n] = h[n] N g[n]
60
Copyright © 2001, S. K. Mitra
Circular Convolution
• Example - Determine the 4-point circular
convolution of the two length-4 sequences:
{g [n]} = {1 2 0 1}, {h[n]} = {2 2 1 1}
↑ ↑
as sketched below
2 g [n ] 2 h[n ]
1 1
n n
0 1 2 3 0 1 2 3
61
Copyright © 2001, S. K. Mitra
Circular Convolution
• The result is a length-4 sequence yC [n]
given by
3
yC [n] = g[n] 4 h[n] = ∑ g[m] h[〈 n − m〉 4 ],
m =0
0≤n≤3
• From the above we observe
3
yC [0] = ∑ g[m] h[〈− m〉 4 ]
m =0
= g[0] h[0] + g[1] h[3] + g[2] h[2] + g[3] h[1]
62
= (1× 2) + (2 × 1) + (0 × 1) + (1× 2) = 6
Copyright © 2001, S. K. Mitra
Circular Convolution
3
• Likewise yC [1] = ∑ g[m] h[〈1 − m〉 4 ]
m =0
= g [0] h[1] + g [1] h[0] + g [2] h[3] + g [3] h[2]
= (1× 2) + (2 × 2) + (0 × 1) + (1× 1) = 7
3
yC [2] = ∑ g[m] h[〈 2 − m〉 4 ]
m =0
= g [0] h[2] + g [1] h[1] + g [2] h[0] + g [3] h[3]
= (1× 1) + (2 × 2) + (0 × 2) + (1× 1) = 6
63
Copyright © 2001, S. K. Mitra
Circular Convolution
and 3
yC [3] = ∑ g[m] h[〈3 − m〉 4 ]
m =0
= g [0] h[3] + g [1] h[2] + g [2] h[1] + g [3] h[0]
= (1× 1) + (2 × 1) + (0 × 2) + (1× 2) = 5
yC [n]
68
D4 is the 4-point DFT matrix
Copyright © 2001, S. K. Mitra
Circular Convolution
• If YC [k ] denotes the 4-point DFT of yC [n]
then from Table 3.5 we observe
YC [k ] = G[k ] H [k ], 0 ≤ k ≤ 3
• Thus
YC [0] G[0] H [0] 24
YC [1] G[1] H [1] − j 2
Y [2] = G[2] H [2] = 0
C
G[3] H [3] j 2
YC [3]
69
Copyright © 2001, S. K. Mitra
Circular Convolution
• A 4-point IDFT of YC [k ] yields
yC [0] YC [0]
yC [1] 1 * YC [1]
y [2] = 4 D4 Y [2]
C
C
yC [3] YC [3]
1 1 1 1 24 6
1 1 j − 1 − j − j 2 7
= =
4 1 − 1 1 − 1 0 6
1 − j − 1 j j 2 5
70
Copyright © 2001, S. K. Mitra
Circular Convolution
• Example - Now let us extended the two
length-4 sequences to length 7 by
appending each with three zero-valued
samples, i.e.
g [n], 0 ≤ n ≤ 3
g e [n] =
0, 4≤n≤6
h[n], 0 ≤ n ≤ 3
he [n] =
0, 4≤n≤6
71
Copyright © 2001, S. K. Mitra
Circular Convolution
• We next determine the 7-point circular
convolution of g e [n]and he [n]:
6
y[n] = ∑ g e [m]he [〈 n − m〉 7 ], 0 ≤ n ≤ 6
m =0
• From the above y[0] = g e [0]he [0] + g e [1]he [6]
+ g e [3]he [4] + g e [4]he [3] + g e [5]he [2] + g e [6]he [1]
= g [0]h[0] = 1× 2 = 2
72
Copyright © 2001, S. K. Mitra
Circular Convolution
• Continuing the process we arrive at
y[1] = g [0]h[1] + g [1]h[0] = (1× 2) + (2 × 2) = 6,
y[2] = g [0]h[2] + g [1]h[1] + g [2]h[0]
= (1× 1) + (2 × 2) + (0 × 2) = 5,
y[3] = g [0]h[3] + g [1]h[2] + g [2]h[1] + g [3]h[0]
= (1× 1) + (2 × 1) + (0 × 2) + (1× 2) = 5,
y[4] = g [1]h[3] + g [2]h[2] + g [3]h[1]
73 = (2 × 1) + (0 × 1) + (1× 2) = 4,
Copyright © 2001, S. K. Mitra
Circular Convolution
y[5] = g [2]h[3] + g [3]h[2] = (0 × 1) + (1× 1) = 1,
y[6] = g [3]h[3] = (1× 1) = 1
• As can be seen from the above that y[n] is
precisely the sequence y L [n] obtained by a
linear convolution of g[n] and h[n]
yL [n]
74
Copyright © 2001, S. K. Mitra
Circular Convolution
• The N-point circular convolution can be
written in matrix form as
yC [0] h[0] h[ N −1] h[ N − 2] L h[1] g [ 0]
yC [1] h[1] h[ 0] h[ N −1] L h[ 2] g [1]
yC [ 2] = h[ 2] h[1] h[ 0] L h[3] g [ 2]
M M
y [ NM −1] h[ NM −1] M M O
h[ 0] g [ N −1]
C h[ N − 2] h[ N −3] L