You are on page 1of 32

Discrete Fourier Transform

and Signal Spectrum


Contents
1. Discrete Fourier Transform
2. Amplitude Spectrum and Power
Spectrum
3. Spectral Estimation Using Window
Functions
4. Fast Fourier Transform

4. Digital Fourier Transform and Signal Spectrum (1) 2


Objectives
 Investigates Discrete Fourier Transform (DFT)
and Fast Fourier Transform (FFT), and their
properties
 Introduces the DFT/FFT algorithms that compute
the signal amplitude spectrum and power
spectrum
 Uses the window function to reduce spectral
leakage
 Describes the FFT algorithm and shows how to
apply FFT to estimate a speech spectrum

4. Digital Fourier Transform and Signal Spectrum (1) 3


Discrete Fourier Transform
Applications

 Signal analysis in frequency domain


 Reduce the amount of data in frequency domain
– Transmit a sinusoidal waveform: only one frequency
component
– DCT(Discrete Cosine Transform): used in speech, image
and video compressions
– Storing medical signal: EEG, ECG
 Feature extraction
– speech recognition, pattern recognition, classification
 Convolution sum in time  multiplication in
frequency
– Fast computation of convolution and correlation

4. Digital Fourier Transform and Signal Spectrum (1) 4


DFT
Definition of DFT (1)

 DTFT
– Discrete-time, non-periodic

 𝑋 𝑒 𝑗Ω = ෍ 𝑥 𝑛 𝑒 −𝑗Ω𝑛 , Ω ≤ 𝜋 ∶ continuous−frequency
𝑛=−∞

 DTFT with finite input sequence


– Practical systems have a finite input sequence:
𝑁−1

𝑋 𝑒 𝑗Ω = ෍ 𝑥 𝑛 𝑒 −𝑗Ω𝑛 , 0 ≤ Ω ≤ 2𝜋.
𝑛=0

– 𝑋 𝑒 𝑗Ω is obtained from the discrete-time signal, but it


is a continuous periodic signal in frequency domain.

4. Digital Fourier Transform and Signal Spectrum (1) 5


DFT
Definition of DFT (2)

 Sampling in frequency domain


– Take 𝑀 equidistant samples in the interval 0 ≤ Ω ≤ 2𝜋 with
2𝜋
spacing ∆Ω = .
𝑀
𝑁−1
2𝜋
−𝑗 𝑀 𝑘𝑛
 𝑋𝑀 𝑒 𝑗Ω
=𝑋 𝑒 𝑗𝑘∆Ω
= ෍𝑥 𝑛 𝑒 , 𝑘 = 0,1, ⋯ , 𝑀 − 1
𝑛=0

𝑋 𝑒 𝑗Ω

𝑋 𝑒 𝑗𝑘∆Ω

Ω
𝑘∆Ω ∆Ω

4. Digital Fourier Transform and Signal Spectrum (1) 6


DFT
Definition of DFT (3)

– If the discrete periodic spectrum is transformed


inversely, it becomes a discrete periodic signal 𝑥𝑀 𝑛
with a period of 𝑀.
– If 𝑀 < 𝑁, the reconstructed periodic signal 𝑥𝑀 𝑛 from
𝑋𝑀 𝑒 𝑗Ω has a time domain aliasing. (Figure1)
– The spectrum of an aperiodic discrete-time signal with
finite duration 𝑁 can be exactly recovered from its
samples at frequencies Ω𝑘 = 2𝜋𝑘Τ𝑀 if 𝑀 ≥ 𝑁.

4. Digital Fourier Transform and Signal Spectrum (1) 7


DFT
Definition of DFT (4)

𝑀≥𝑁

𝑁 𝑀

𝑀<𝑁

−𝑀 𝑀
Figure 1. Aperiodic sequence 𝑥 𝑛 of length 𝐿 and its periodic
extension for 𝑀 ≥ 𝑁 (no aliasing) and 𝑀 < 𝑁 (aliasing).

4. Digital Fourier Transform and Signal Spectrum (1) 8


DFT
Definition of DFT (5)

 DFT
𝑁−1

 DFT: 𝑋 𝑘 = ෍ 𝑥 𝑛 𝑒 −𝑗2𝜋𝑘𝑛/𝑁 , 𝑘 = 0,1,2, ⋯ , 𝑁 − 1


𝑛=0
𝑁−1
1
 IDFT: 𝑥 𝑛 = ෍ 𝑋 𝑘 𝑒 𝑗2𝜋𝑘𝑛/𝑁 , 𝑛 = 0,1,2, ⋯ , 𝑁 − 1
𝑁
𝑘=0

4. Digital Fourier Transform and Signal Spectrum (1) 9


DFT
DFT Formulas (1)

 DFT
Given a sequence 𝑥(𝑛), 0 ≤ 𝑛 ≤ 𝑁 − 1, its DFT is defined as
𝑁−1 𝑁−1

𝑋 𝑘 = ෍ 𝑥 𝑛 𝑒 −𝑗2𝜋𝑘𝑛/𝑁 = ෍ 𝑥 𝑛 𝑊𝑁𝑘𝑛 , 𝑘 = 0,1,2, ⋯ , 𝑁 − 1


𝑛=0 𝑛=0
2𝜋 2𝜋
 𝑊𝑁 = 𝑒 −𝑗2𝜋/𝑁 = cos − 𝑗 sin ∶ Twiddle factor 회전인자
𝑁 𝑁

 Inverse DFT
𝑁−1 𝑁−1
1 1
𝑥 𝑛 = ෍𝑋 𝑘 𝑒 𝑗2𝜋𝑛𝑘/𝑁 = ෍ 𝑋 𝑘 𝑊𝑁−𝑘𝑛 , 𝑛 = 0,1,2, ⋯ , 𝑁 − 1
𝑁 𝑁
𝑘=0 𝑘=0

4. Digital Fourier Transform and Signal Spectrum (1) 10


DFT
DFT Formulas (2)

Ex 4.2 Given a sequence 𝑥(𝑛) for 0 ≤ 𝑛 ≤ 3, where


𝑥(0) = 1, 𝑥(1) = 2, 𝑥(2) = 3 and 𝑥(3) = 4.
a. Evaluate its DFT 𝑋(𝑘).
Ex 4.3 Using the DFT coefficients 𝑋(𝑘) for 0 ≤ 𝑘 ≤ 3
computed on Ex 4.2.
a. Evaluate its inverse DFT to determine the time domain
sequence 𝑥(𝑛).
4. Digital Fourier Transform and Signal Spectrum (1) 11
DFT
DFT Formulas (3)

 Frequency resolution
𝜔𝑠
 ∆𝜔 = radians per second
𝑁
𝑓𝑠
 ∆𝑓 = Hz
𝑁
 The relationship between the frequency bin 𝑘 and
its associated frequency
𝑘𝜔𝑠
 ω = 𝑘∆𝜔 = radians per second
𝑁
𝑘𝑓𝑠
 𝑓 = 𝑘∆𝑓 = Hz
𝑁

4. Digital Fourier Transform and Signal Spectrum (1) 12


DFT
DFT Formulas (4)

Ex. 4.4 In example 4.2, given a sequence 𝑥(𝑛) for


0 ≤ 𝑛 ≤ 3, where 𝑥(0) = 1, 𝑥(1) = 2, 𝑥(2) = 3, and 𝑥(3) =
4, we computed 4 DFT coefficients 𝑋(𝑘) for 0 ≤ 𝑘 ≤ 3,
as 𝑋(0) = 10, 𝑋(1) = −2 + 𝑗2, 𝑋(2) = −2, and 𝑋(3) = −2 −
𝑗2. If the sampling rat is 10 Hz,
a. Determine the sampling period, time index, and
sampling time instant for a digital sample 𝑥(3) in
the time domain.
b. Determine the frequency resolution, frequency
bin, and mapped frequencies for the DFT
coefficients 𝑋(1) and 𝑋(3) in the fequency
domain.

4. Digital Fourier Transform and Signal Spectrum (1) 13


Amplitude/Power Spectrum
Introduction

 Transformation of a finite-length digital signal


𝑥(𝑛) into the spectrum in frequency domain

4. Digital Fourier Transform and Signal Spectrum (1) 14


Amplitude/Power Spectrum
Amplitude Spectrum

 Amplitude Spectrum
1 1 2 2, 𝑘
𝐴𝑘 = 𝑋 𝑘 = Re 𝑋 𝑘 + Im 𝑋 𝑘 = 0, 1, 2, ⋯ , 𝑁 − 1
𝑁 𝑁
 One-sided amplitude spectrum
1
𝑋 0 , 𝑘=0
– 𝐴ҧ𝑘 = 𝑁
2 𝑁
𝑋 𝑘 , 𝑘 = 1, 2, ⋯ ,
𝑁 2

 Phase spectrum
Im 𝑋 𝑘
– 𝜙𝑘 = tan−1 , 𝑘 = 0, 1, 2, ⋯ , 𝑁 − 1
Re 𝑋 𝑘

4. Digital Fourier Transform and Signal Spectrum (1) 15


Amplitude/Power Spectrum
Power Spectrum

 Power Spectrum
1
𝑃𝑘 = 𝐴2𝑘 = 2 𝑋 𝑘 2
𝑁
1 2 2
= 2 Re 𝑋 𝑘 + Im 𝑋 𝑘 , 𝑘 = 0, 1, 2, ⋯ , 𝑁 − 1
𝑁
 One-sided power spectrum
1 2,
2
𝑋 0 𝑘=0
𝑃𝑘 = 𝑁
2 2,
𝑁
2
𝑋 𝑘 𝑘 = 1, 2, ⋯ ,
𝑁 2

 Ex 4.5, Ex 4.6

4. Digital Fourier Transform and Signal Spectrum (1) 16


Amplitude/Power Spectrum
Example 4.5

Consider the sequence in Figure 4.8. Assuming that


𝑓𝑠 = 100 Hz, compute the amplitude spectrum,
phase spectrum, and power spectrum.

4. Digital Fourier Transform and Signal Spectrum (1) 17


Amplitude/Power Spectrum
Example 4.6

Consider a digital sequence sampled at the rate of


10 kHz. If we use 1,024 data points and apply the
1024-point DFT to compute the spectrum,
a. Determine the frequency resolution
b. Determine the highest frequency in the
spectrum.

4. Digital Fourier Transform and Signal Spectrum (1) 18


Amplitude/Power Spectrum
FFT (1)
 Requires the time domain sequence 𝑥(𝑛) to have
a length of data points equal to a power of 2
 When the length is not equal to a power of 2, pad
the data sequence with zeros
𝑥 𝑛 , 0≤𝑛 ≤𝑁−1
𝑥ҧ 𝑛 = ቊ ഥ − 1, 𝑁
ഥ = 2𝑚 > 𝑁
0, 𝑁≤𝑛≤𝑁
 No. of complex multiplications and additions
– DFT: 𝑁2, 𝑁(𝑁 − 1)
𝑁
 FFT: log 2 𝑁 , 𝑁 log 2 𝑁
2

4. Digital Fourier Transform and Signal Spectrum (1) 19


Amplitude/Power Spectrum
FFT (2)
 Signal spectra obtained via zero-padding
– Does not add any new information.
– Does not contain more accurate signal spectral
presentation.
– Frequency spacing is reduced due to more DFT points.
– Achieved spectrum is an interpolated version with
“better display”.

 The only way to obtain the detailed signal


spectrum with a fine frequency resolution
– Apply more available data samples

4. Digital Fourier Transform and Signal Spectrum (1) 20


Amplitude/Power Spectrum
FFT (3)
 Zero padding effect by using FFT
a. 12 data samples
(10 Hz, 25 Hz)
b. Padding 4 zeros
 16 data samples
c. Padding 20 zeros
 32 data samples

4. Digital Fourier Transform and Signal Spectrum (1) 21


Amplitude/Power Spectrum
FFT (4)
Ex 4.7 We use the DFT to compute the amplitude spectrum of
a sampled data sequence with a sampling rate 𝑓𝑠 = 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.
Sol)
𝑓𝑠
Δ𝑓 = < 0.5 𝐻𝑧
𝑁
𝑁 > 2𝑓𝑠 = 20,000
𝑁 = 215 = 32,768
𝑓𝑠
Δ𝑓 = = 10,000/32,768 = 0.305 𝐻𝑧
𝑁

4. Digital Fourier Transform and Signal Spectrum (1) 22


Amplitude/Power Spectrum
Example 4.8 (1)
𝑛
Consider the sinusoid 𝑥 𝑛 = 2 sin 2000𝜋 ∙ obtained by
8,000
sampling the analog signal 𝑥 𝑡 = 2 sin 2000𝜋𝑡 with a sampling
rate of 𝑓𝑠 = 8,000 Hz.
a. Use the MATLAB DFT to compute the signal spectrum
where the frequency resolution is equal to or less than
8 Hz.
Sol) Δ𝑓 = 𝑓𝑠/𝑁 ≤ 8 𝐻𝑧, 𝑁 ≥ 1000
b. Use the MATLAB FFT and zero padding to compute the
signal spectrum, assuming that the data samples in (a)
are available.
Sol) N should be a power of 2.
N = 210 = 1024
Zero padding x = [x, zeros(1,24)];

4. Digital Fourier Transform and Signal Spectrum (1) 23


Amplitude/Power Spectrum
MATLAB program for Example 4.8 (1)

% MATLAB Program 4.1


% Example 4.8
close all; clear all
% Generate the sine wave sequence
fs=8000; %Sampling rate
N=1000; % number of data points
x=2*sin(2000*pi*[0:1:N-1]/fs);
% Apply the DFT algorithm
X=x*dftmtx(N); % DFT using NxN matrix of linear transform
xf=abs(X)/N; % Compute the amplitude spectrum

4. Digital Fourier Transform and Signal Spectrum (1) 24


Amplitude/Power Spectrum
MATLAB program for Example 4.8 (2)

P=xf.*xf; % Compute power spectrum


f=[0:1:N-1]*fs/N; % Map the frequency bin to frequency(Hz)
% Plotting
figure(1)
subplot(2,1,1); plot(f,xf);grid
xlabel('Frequency (Hz)');
ylabel('Amplitude spectrum (DFT)');
subplot(2,1,2); plot(f,P);grid
xlabel('Frequency (Hz)');
ylabel('Power spectrum (DFT)');

4. Digital Fourier Transform and Signal Spectrum (1) 25


Amplitude/Power Spectrum
MATLAB program for Example 4.8 (3)

% One-sided spectrum
figure(2)
xf(2:N/2+1)=2*xf(2:N/2+1); % Get the one-sided spectrum
P(2:N/2+1)=2*P(2:N/2+1); % Calculate the power spectrum
f=[0:1:N/2]*fs/N % frequencies up to the folding frequency
subplot(2,1,1); plot(f,xf(1:N/2+1));grid
xlabel('Frequency (Hz)'); ylabel('Amplitude spectrum (DFT)');
subplot(2,1,2);plot(f,P(1:N/2+1));grid
xlabel('Frequency (Hz)'); ylabel('Power spectrum (DFT)');

4. Digital Fourier Transform and Signal Spectrum (1) 26


Amplitude/Power Spectrum
MATLAB program for Example 4.8 (4)

% Apply FFT algorithm


x=[x,zeros(1,24)]; % zero padding to the length of 1024
N=length(x);
xf=abs(fft(x))/N; % Compute amplitude spectrum
P=xf.*xf; % Compute power spectrum
f=[0:1:N-1]*fs/N; % Map frequency bin to frequency (Hz)
figure (3)
subplot(2,1,1); plot(f,xf); grid
xlabel('Frequency (Hz)'); ylabel('Amplitude spectrum (FFT)');
subplot(2,1,2);plot(f,P);grid
xlabel('Frequency (Hz)'); ylabel('Power spectrum (FFT)');
4. Digital Fourier Transform and Signal Spectrum (1) 27
Amplitude/Power Spectrum
MATLAB program for Example 4.8 (5)

% Convert two-sided spectrum to one-sided spectrum


figure(4)
xf(2:N/2+1)=2*xf(2:N/2+1);
P(2:N/2+1)=2*P(2:N/2+1);
f=[0:1:N/2]*fs/N;
subplot(2,1,1);
plot(f,xf(1:N/2+1));grid
xlabel('Frequency (Hz)'); ylabel('Amplitude spectrum (FFT)');
subplot(2,1,2);
plot(f,P(1:N/2+1));grid
xlabel('Frequency (Hz)'); ylabel('Power spectrum (FFT)');
4. Digital Fourier Transform and Signal Spectrum (1) 28
Amplitude/Power Spectrum
MATLAB results for Example 4.8 (1)

Amplitude spectrum (DFT) 1

0.5

0
0 1000 2000 3000 4000 5000 6000 7000 8000
Frequency (Hz)

1
Power spectrum (DFT)

0.5

0
0 1000 2000 3000 4000 5000 6000 7000 8000
Frequency (Hz)

4. Digital Fourier Transform and Signal Spectrum (1) 29


Amplitude/Power Spectrum
MATLAB results for Example 4.8 (2)

Amplitude spectrum (DFT)


2

1.5

0.5

0
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)

2
Power spectrum (DFT)

1.5

0.5

0
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)

4. Digital Fourier Transform and Signal Spectrum (1) 30


Amplitude/Power Spectrum
MATLAB results for Example 4.8 (3)

Amplitude spectrum (FFT) 1

0.5

0
0 1000 2000 3000 4000 5000 6000 7000 8000
Frequency (Hz)

1
Power spectrum (FFT)

0.5

0
0 1000 2000 3000 4000 5000 6000 7000 8000
Frequency (Hz)

4. Digital Fourier Transform and Signal Spectrum (1) 31


Amplitude/Power Spectrum
MATLAB results for Example 4.8 (4)

Amplitude spectrum (FFT)


2

1.5

0.5

0
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)

2
Power spectrum (FFT)

1.5

0.5

0
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)

4. Digital Fourier Transform and Signal Spectrum (1) 32

You might also like