Lecture 5 PDF
Lecture 5 PDF
MEC 222
Chapter Three
Discrete Time Fourier Transform
In the time domain, representation of digital signals describes the signal amplitude versus
the sampling time instant or the sample number.
However, in some applications, signal frequency content is very useful in ways other than
as digital signal samples.
The representation of the digital signal in terms of its frequency component in a frequency
domain, that is, the signal spectrum, needs to be developed.
2
1- Discrete Fourier Transform
As an example, Next figure illustrates in left plot the time domain representation of a
1kHz sinusoid with 32 samples at a 𝑓𝑓𝑠𝑠 = 8 kHz;
the right plot shows the signal spectrum (frequency domain representation), where we can
clearly observe that the amplitude peak is located at the frequency of 1 kHz in the
calculated spectrum. Hence, the spectral plot better displays the frequency information of
a digital signal.
3
1- Discrete Fourier Transform
The algorithm transforming the time domain signal samples to the frequency domain
components is known as the discrete Fourier transform, or DFT.
Applications of DFT
Perform Spectral analysis of a time domain sequence
Acoustics.
imaging/video processing.
Audio.
Instrumentation.
Communications systems
4
2- Discrete Fourier Transform Formulas
5
2- Discrete Fourier Transform Formulas
Discrete-time Fourier transform (DFT) of x[n] as
𝑁𝑁−1 𝑁𝑁−1
2𝜋𝜋𝜋𝜋𝜋𝜋
−𝑗𝑗
𝑋𝑋 𝑘𝑘 = � 𝑥𝑥 𝑛𝑛 𝑒𝑒 𝑁𝑁 = � 𝑥𝑥 𝑛𝑛 𝑊𝑊𝑁𝑁𝑛𝑛𝑛𝑛 𝑘𝑘 = 0,1, … , 𝑁𝑁 − 1
𝑛𝑛=0 𝑛𝑛=0
We can see in the above equation for the DFT that X(k) is finite, x(n) is finite and the number of points in x(n) is
the same as the number of points in X(k). 6
2- Inverse Discrete Fourier Transform (IDFT) Formulas
To go back to the discrete time signal x(n) from the X(k) values, we use the inverse relation
𝑁𝑁−1 𝑁𝑁−1
1 2𝜋𝜋𝜋𝜋𝜋𝜋
𝑗𝑗 𝑁𝑁 1
x 𝑛𝑛 = � 𝑋𝑋 𝑘𝑘 𝑒𝑒 = � 𝑋𝑋 𝑘𝑘 𝑊𝑊𝑁𝑁−𝑛𝑛𝑛𝑛 𝑛𝑛 = 0,1, … , 𝑁𝑁 − 1
𝑁𝑁 𝑁𝑁
𝑘𝑘=0 𝑘𝑘=0
OR
𝑁𝑁−1 𝑁𝑁−1
1 2𝜋𝜋𝜋𝜋𝜋𝜋
−𝑗𝑗 𝑁𝑁 1
∗
x 𝑛𝑛 = � 𝑋𝑋 𝑘𝑘 𝑒𝑒 = � 𝑋𝑋 ∗ 𝑘𝑘 𝑊𝑊𝑁𝑁𝑛𝑛𝑛𝑛 𝑛𝑛 = 0,1, … , 𝑁𝑁 − 1
𝑁𝑁 𝑁𝑁
𝑘𝑘=0 𝑘𝑘=0
7
Example 1
Given a sequence x(n) for 0 ≤ 𝑛𝑛 ≤ 1, where x(0)=1, x(1)=2, evaluate its DFT X(k)
Answer
Since N=2, we have to compute the Two twiddle factors
−𝑗𝑗
2𝜋𝜋
×0 𝑾𝑾𝟎𝟎𝟐𝟐 = 𝟏𝟏
𝑊𝑊20 = 𝑒𝑒 2 = 𝑒𝑒 0 =1
𝑾𝑾𝟏𝟏𝟐𝟐 = −𝟏𝟏
𝑗𝑗2𝜋𝜋
𝑊𝑊21 = −
𝑒𝑒 2 ×1 = 𝑒𝑒 −𝑗𝑗𝑗𝑗 = cos 𝜋𝜋 − 𝑗𝑗𝑗𝑗𝑗𝑗𝑗𝑗 𝜋𝜋 = −1
Note that
𝑊𝑊23 = 𝑊𝑊21 𝑊𝑊24 = 𝑊𝑊40 𝑊𝑊27 = 𝑊𝑊21 𝑊𝑊217 = 𝑊𝑊21 𝑊𝑊227 = 𝑊𝑊21 𝑊𝑊2105 = 𝑊𝑊21
8
Example 1
𝑁𝑁−1 𝑾𝑾𝟎𝟎𝟐𝟐 = 𝟏𝟏
𝑾𝑾𝟏𝟏𝟐𝟐 = −𝟏𝟏
𝑋𝑋 𝑘𝑘 = � 𝑥𝑥 𝑛𝑛 𝑊𝑊𝑁𝑁𝑛𝑛𝑛𝑛 𝑘𝑘 = 0,1, … , 𝑁𝑁 − 1
𝑛𝑛=0
For 𝒌𝒌 = 𝟎𝟎
1
𝑋𝑋 𝑘𝑘 = (3, −1)
9
Example 2 Given a sequence X(k) for 0 ≤ 𝑘𝑘 ≤ 1, where X(0)=3, X(1)=-1, evaluate its IDFT x(n)
Answer
𝑾𝑾𝟎𝟎𝟐𝟐 = 𝟏𝟏
Since N=2, we have to compute the Two twiddle factors
𝑾𝑾𝟏𝟏𝟐𝟐 = −𝟏𝟏
𝑁𝑁−1
1
𝑥𝑥 𝑛𝑛 = � 𝑋𝑋 𝑘𝑘 ∗ 𝑊𝑊𝑁𝑁𝑛𝑛𝑛𝑛 𝑛𝑛 = 0,1, … , 𝑁𝑁 − 1
𝑁𝑁
𝑘𝑘=0
𝑋𝑋 ∗ 0 = 3, 𝑋𝑋 ∗ 1 = −1,
For n= 𝟎𝟎
1
1 1 2
𝑥𝑥 0 = � 𝑋𝑋 ∗ 𝑘𝑘 𝑊𝑊𝑁𝑁𝑛𝑛× 0 = 𝑋𝑋 ∗ 0 𝑊𝑊20 + 𝑋𝑋 ∗ 1 𝑊𝑊20 = [3 1 − 1(1)] = = 1
2 2 2
𝑛𝑛=0
For n= 𝟏𝟏
1
1 1 4
𝑥𝑥 1 = � 𝑋𝑋 ∗ 𝑘𝑘 𝑊𝑊𝑁𝑁𝑛𝑛×1 = 𝑋𝑋 ∗ 0 𝑊𝑊20 + 𝑋𝑋 ∗ 1 𝑊𝑊21 = 3 1 − 1(−1) = = 2
2 2 2
𝑛𝑛=0
x 𝑛𝑛 = (1,2)
10
Example 3 Given a sequence x(n) for 0 ≤ 𝑛𝑛 ≤ 3, where x(0)=1, x(1)=2,x(2)=3, and x(3)=4, evaluate its DFT X(k)
Answer
2𝜋𝜋
−𝑗𝑗 ×0
𝑊𝑊40 = 𝑒𝑒 4 = 𝑒𝑒 0 = 1
𝑗𝑗2𝜋𝜋 2𝜋𝜋𝜋𝜋 𝜋𝜋
𝑊𝑊41 = −
𝑒𝑒 4 ×1 = 𝑒𝑒 −𝑗𝑗
= cos4 − 𝑗𝑗𝑗𝑗𝑗𝑗𝑗𝑗 = −𝑗𝑗
2 2 𝑾𝑾𝟎𝟎𝟒𝟒 = 𝟏𝟏
2 −
𝑗𝑗2𝜋𝜋
×2 −𝑗𝑗
𝜋𝜋 𝜋𝜋 𝜋𝜋 𝑾𝑾𝟏𝟏𝟒𝟒 = −𝒋𝒋
𝑊𝑊4 = 𝑒𝑒 4 = 𝑒𝑒 4 = cos − 𝑗𝑗𝑗𝑗𝑗𝑗𝑗𝑗 = −1
4 4 𝑾𝑾𝟐𝟐𝟒𝟒 = −𝟏𝟏
𝑗𝑗2𝜋𝜋 𝜋𝜋 𝜋𝜋 𝜋𝜋 𝑾𝑾𝟑𝟑𝟒𝟒 = 𝒋𝒋
3 − ×2 −𝑗𝑗
𝑊𝑊4 = 𝑒𝑒 4 = 𝑒𝑒 4 = cos − 𝑗𝑗𝑗𝑗𝑗𝑗𝑗𝑗 = 𝑗𝑗
4 4
Note that
𝑊𝑊45 = 𝑊𝑊41 𝑊𝑊46 = 𝑊𝑊42 𝑊𝑊47 = 𝑊𝑊43 𝑊𝑊417 = 𝑊𝑊41 𝑊𝑊427 = 𝑊𝑊43 𝑊𝑊4105 = 𝑊𝑊41
11
𝑁𝑁−1
Example 3 𝑾𝑾𝟎𝟎𝟒𝟒 = 𝟏𝟏
𝑋𝑋 𝑘𝑘 = � 𝑥𝑥 𝑛𝑛 𝑊𝑊𝑁𝑁𝑛𝑛𝑛𝑛 𝑘𝑘 = 0,1, … , 𝑁𝑁 − 1 𝑾𝑾𝟏𝟏𝟒𝟒 = −𝒋𝒋
𝑛𝑛=0 𝑾𝑾𝟐𝟐𝟒𝟒 = −𝟏𝟏
𝑾𝑾𝟑𝟑𝟒𝟒 = 𝒋𝒋
For 𝒌𝒌 = 𝟎𝟎
3
For 𝒌𝒌 = 𝟐𝟐
3
For 𝒌𝒌 = 𝟑𝟑
3
Answer
𝑁𝑁−1 𝑾𝑾𝟎𝟎𝟒𝟒 = 𝟏𝟏
1
𝑥𝑥 𝑛𝑛 = � 𝑋𝑋 𝑘𝑘 ∗ 𝑊𝑊𝑁𝑁𝑛𝑛𝑛𝑛 𝑛𝑛 = 0,1, … , 𝑁𝑁 − 1 𝑾𝑾𝟏𝟏𝟒𝟒 = −𝒋𝒋
𝑁𝑁 𝑾𝑾𝟐𝟐𝟒𝟒 = −𝟏𝟏
𝑘𝑘=0
𝑾𝑾𝟑𝟑𝟒𝟒 = 𝒋𝒋
𝑋𝑋 ∗ 0 = 10, 𝑋𝑋 ∗ 1 = −2 − 2𝑗𝑗, 𝑋𝑋 ∗ 2 = −2, 𝑋𝑋 ∗ 3 = −2 + 2𝑗𝑗
For n= 𝟎𝟎
3
1 ∗ 𝑛𝑛× 0 ∗ 0 ∗ 0 ∗ 0 ∗ 0
1 4
𝑥𝑥 0 = � 𝑋𝑋 𝑘𝑘 𝑊𝑊𝑁𝑁 = 𝑋𝑋 0 𝑊𝑊4 + 𝑋𝑋 1 𝑊𝑊4 + 𝑋𝑋 2 𝑊𝑊4 + 𝑋𝑋 3 𝑊𝑊4 = [10 − 2 − 2𝑗𝑗 − 2 − 2 + 2𝑗𝑗] = = 1
4 4 4
𝑛𝑛=0
For n= 𝟏𝟏
3
1 1 8
𝑥𝑥 1 = � 𝑋𝑋 ∗ 𝑘𝑘 𝑊𝑊𝑁𝑁𝑛𝑛×1 = 𝑋𝑋 ∗ 0 𝑊𝑊40 + 𝑋𝑋 ∗ 1 𝑊𝑊41 + 𝑋𝑋 ∗ 2 𝑊𝑊42 + 𝑋𝑋 ∗ 3 𝑊𝑊43 = 10 − 𝑗𝑗 −2 − 2𝑗𝑗 − 2 −1 + 𝑗𝑗 −2 + 2𝑗𝑗 = =2
4 4 4
𝑛𝑛=0
For n= 𝟐𝟐
3
1 1 12
𝑥𝑥 1 = � 𝑋𝑋 ∗ 𝑘𝑘 𝑊𝑊𝑁𝑁𝑛𝑛×2 = 𝑋𝑋 ∗ 0 𝑊𝑊40 + 𝑋𝑋 ∗ 1 𝑊𝑊42 + 𝑋𝑋 ∗ 2 𝑊𝑊40 + 𝑋𝑋 ∗ 3 𝑊𝑊42 = [10 − −2 − 2𝑗𝑗 − 2 1 − −2 + 2𝑗𝑗 ] = =3
4 4 4
𝑛𝑛=0
For n= 𝟑𝟑
3
1 1 16
𝑥𝑥 1 = � 𝑋𝑋 ∗ 𝑘𝑘 𝑊𝑊𝑁𝑁𝑛𝑛×2 = 𝑋𝑋 ∗ 0 𝑊𝑊40 + 𝑋𝑋 ∗ 1 𝑊𝑊43 + 𝑋𝑋 ∗ 2 𝑊𝑊42 + 𝑋𝑋 ∗ 3 𝑊𝑊41 = [10 + 𝑗𝑗 −2 − 2𝑗𝑗 − 2 −1 − 𝑗𝑗 −2 + 2𝑗𝑗 ] = =4
4 4 4
𝑛𝑛=0
x 𝑛𝑛 = (1,2,3,4) 13
The relationship between the frequency bin (k) and its associated frequency.
𝑘𝑘
𝑓𝑓 = 𝑓𝑓𝑠𝑠 (𝐻𝐻𝐻𝐻)
𝑁𝑁
The frequency step between two consecutive DFT coefficients to measure how fine the frequency domain
presentation is and obtain
𝑓𝑓𝑠𝑠
Δ𝑓𝑓 = 𝑘𝑘 × (𝐻𝐻𝐻𝐻)
𝑁𝑁
14
Example 5 In Example 3, given a sequence x(n)=[1,2,3,4] we computed 4 DFT coefficients X(k)=(10,-2+2j,-2,-2-2j). If the
sampling rate is 10 Hz.
a) determine the sampling period, time index, and sampling time instant for a digital sample x(3) in the time domain;
b) determine the frequency resolution, frequency bin, and mapped frequencies for the DFT coefficients x(1) and X(3) in the
frequency domain
Answer
a) In the time domain, the sampling period is calculated as
1 1
𝑇𝑇 = = = 0.1 𝑆𝑆
𝑓𝑓𝑠𝑠 10
For x(3) the time index is n = 3 and the sampling time instant is determined by
𝑡𝑡 = 𝑛𝑛𝑛𝑛 = 3 × 0.1 = 0.3 𝑆𝑆
b) In the frequency domain, since the total number of DFT coefficients is four, the frequency resolution is determined by
𝑓𝑓𝑠𝑠 10
Δ𝑓𝑓 = 𝑘𝑘 × = = 2.5 𝐻𝐻𝐻𝐻
𝑁𝑁 4
The frequency bin for X(1) should be k = 1 and its corresponding frequency is determined by
10
𝑓𝑓 = 1 × = 2.5 (𝐻𝐻𝐻𝐻)
4
The frequency bin for X(3) should be k = 3 and its corresponding frequency is determined by
10
𝑓𝑓 = 3 × = 7.5 (𝐻𝐻𝐻𝐻) 15
4
x(n)
Example 5 x(3)
x(2)
x(1)
x(0)
n
0 1 2 3
t=nT
0 0.1 0.2 0.3
X(k)
X(0)
k
0 1 2 3 𝑓𝑓𝑠𝑠
𝑓𝑓 = 𝑘𝑘
𝑁𝑁
0 0.25 0.5 0.75
16
4.2 AMPLITUDE SPECTRUM AND POWER SPECTRUM
Since each calculated DFT coefficient is a complex number, it is not convenient to plot it versus its frequency
index.
Hence, the magnitude and phase of each DFT coefficient (we refer to them as the amplitude spectrum and
phase spectrum, respectively) can be determined and plotted versus its frequency index.
𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼 𝑋𝑋 𝑘𝑘
𝜙𝜙𝑘𝑘 = tan−1 , 𝑘𝑘 = 0,1,2, … , 𝑁𝑁 − 1
𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 𝑋𝑋 𝑘𝑘
The power spectrum is
1 2
1 2 2 },
𝑃𝑃𝑘𝑘 = 𝑋𝑋 𝑘𝑘 = 𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 𝑋𝑋 𝑘𝑘 + 𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼 𝑋𝑋 𝑘𝑘 𝑘𝑘 = 0,1,2, … . 𝑁𝑁 − 1
𝑁𝑁 2 𝑁𝑁 2
17
Example 6
Consider the sequence in next figure. Assuming that 𝑓𝑓𝑠𝑠 = 10 𝐻𝐻𝐻𝐻, compute the amplitude spectrum, phase spectrum, and
power spectrum.
Answer
Since N =4, and using the DFT shown in Example 3, we find the DFT coefficients to be
X(0)= 10
X(1)= -2+2j
X(2)= -2
X(3)= -2-2j
18
Example 6
The amplitude spectrum, phase spectrum, and power density spectrum are computed as follows:
kfs
𝐹𝐹𝐹𝐹𝐹𝐹 𝑘𝑘 = 0, 𝑓𝑓 = = 0 𝐻𝐻𝐻𝐻,
𝑁𝑁
1 𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖 𝑋𝑋 0 1
𝐴𝐴0 = 𝑋𝑋 0 = 2.5, 𝜙𝜙0 = tan−1 = 00 , 𝑃𝑃0 = 2 𝑋𝑋 0 2 = 6.25
4 𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 𝑋𝑋 0 4
kfs 1 × 10
𝐹𝐹𝐹𝐹𝐹𝐹 𝑘𝑘 = 1, 𝑓𝑓 = = = 2.5 𝐻𝐻𝐻𝐻,
𝑁𝑁 4
1 𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖 𝑋𝑋 1 1
𝐴𝐴1 = 𝑋𝑋 1 = 0.707, 𝜙𝜙1 = tan−1 = 1350 , 𝑃𝑃1 = 𝑋𝑋 1 2 = 0.5
4 𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 𝑋𝑋 1 42
kfs 2 × 10
𝐹𝐹𝐹𝐹𝐹𝐹 𝑘𝑘 = 2, 𝑓𝑓 = = = 0.5 𝐻𝐻𝐻𝐻,
𝑁𝑁 4
1 𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖 𝑋𝑋 2 1
𝐴𝐴2 = 𝑋𝑋 2 = 0.5, 𝜙𝜙2 = tan−1 = 00 , 𝑃𝑃2 = 𝑋𝑋 2 2 = 0.25
4 𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 𝑋𝑋 2 42
kfs 3 × 10
𝐹𝐹𝐹𝐹𝐹𝐹 𝑘𝑘 = 3, 𝑓𝑓 = = = 7.5 𝐻𝐻𝐻𝐻,
𝑁𝑁 4
1 𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖 𝑋𝑋 3 1
𝐴𝐴3 = 𝑋𝑋 3 = 0.707, 𝜙𝜙3 = tan−1 = −1350 , 𝑃𝑃3 = 𝑋𝑋 3 2
= 0.5
4 𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 𝑋𝑋 3 42
19
Example 6
20
Example 7
Consider a digital sequence sampled at the rate of 10 kHz. If we use 1,024 data points and apply the 1,024-point DFT to
compute the spectrum,
a. determine the frequency resolution;
b. determine the highest frequency in the spectrum.
Answer
𝑓𝑓𝑠𝑠 10000
a) Δ𝑓𝑓 = = = 9.776 𝐻𝐻𝐻𝐻
𝑁𝑁 1024
𝑁𝑁 𝑓𝑓𝑠𝑠
𝑓𝑓𝑚𝑚𝑚𝑚𝑚𝑚 = Δ𝑓𝑓 = = 5000 𝐻𝐻𝐻𝐻
2 2
21
4.3 FAST FOURIER TRANSFORM
From inspection Equations of DFT and IDFT , we see that for each value of k, computation of will require N
multiplications.
Because x[n] and especially x[k], can have complex values, the computation of an N-point DFT or the inverse
DFT generally requires 𝑁𝑁 2 complex multiplications.
We start with and work our way up to before we try to generalize the process. The result of our efforts is known
as the decompositionin- time, radix-2 FFT.
22
4.3.1 Decomposition-in-Time FFT
𝑊𝑊20 = 1
𝑊𝑊21 = −1
𝑊𝑊20
𝑋𝑋 0 = 𝑥𝑥 0 + 𝑊𝑊20 𝑥𝑥(1)
𝑊𝑊21
𝑋𝑋 1 = 𝑥𝑥 0 + 𝑊𝑊21 𝑥𝑥(1)
23
Example 4
1 1
𝑤𝑤20
X(0)=1+1*0=1
X(1)=1-1*0= 1
𝑤𝑤21
0 1
24
4.3.1 Decomposition-in-Time FFT
4 points FFT
𝑤𝑤21 𝑤𝑤43
4- proceed with the butterfly to get the results
25
Example 5
1 3
Find FFT for x(n)=(2,3,-1,-1) 2
Answer
𝑤𝑤40
Butterfly Normal 𝑤𝑤40
order order 3 3-4j
W40 = 1 -1
X(0) 00 00 𝑤𝑤41
W41 = −j X(2) 10 01 𝑤𝑤41
W42 = −1 X(1) 01 10
W43 = j X(3) 11 11 2
3 -1
𝑤𝑤42
𝑤𝑤20
4 3+4j
-1
𝑤𝑤21 𝑤𝑤43
X(k)=(3,3-4j,-1,3+4j)
26
Example 6
Find IFFT of X(k)=(3, 3-4j , -1, 3+4j )
Answer
2
𝑥𝑥 ∗ 𝑘𝑘 = (3, 3 + 4𝑗𝑗, −1, 3 − 4𝑗𝑗) 3 8
𝑤𝑤40
𝑤𝑤20
4
-1 12
𝑤𝑤21
𝑤𝑤41
x 𝑛𝑛 = (8, 12, −4, −4)*
1
4
6
x 𝑛𝑛 = (2, 3, −1, −1) 3+4j -4
𝑤𝑤42
𝑤𝑤20
8j
3-4j -4
𝑤𝑤21 𝑤𝑤43
27
No. of calculation of DFT and FFT
28
4.4 APPLICATIONS OF THE DISCRETE FOURIER TRANSFORM
1- Linear convolution
29
Example 7
We use the DFT to compute the amplitude spectrum of a sampled data sequence with a sampling
rate fs =10 kHz. Given a requirement that the frequency resolution be less than 0.5 Hz, determine the
number of data points by using the FFT algorithm, assuming that the data samples are available.
Answer
𝑓𝑓𝑠𝑠 10000
𝑁𝑁 = = = 20000
Δ𝑓𝑓 0.5
Since we use the FFT to compute the spectrum, thr number of data points must be power of 2, that is,
𝑁𝑁 = 215 = 32768
𝑓𝑓𝑠𝑠 10000
Δ𝑓𝑓 = = = 0.31 𝐻𝐻𝐻𝐻
𝑁𝑁 32768
30
Sheet 5
3 Repeat problem 1 using FFT , and compare between number of additions and number of multipliers for
each sequence.
31
Sheet 5
5 Consider a digital sequence sampled at the rate of 16,000 Hz. If we use the 4,000-point DFT to compute
the spectrum, determine
6 We use the DFT to compute the amplitude spectrum of a sampled data sequence with a sampling
rate fs = 2000 Hz. It requires the frequency resolution to be less than 0.5 Hz. Determine the number
of data points used by the FFT algorithm and actual frequency resolution in Hz, assuming that the
data samples are available for selecting the number of data points.
32
Sheet 5
7 Given the sequence in Figure and assuming fs = 100 Hz, compute the amplitude spectrum, phase
spectrum, and power spectrum.
33
Sheet 4
(a) (b)
34