SH 8 DFT
SH 8 DFT
Objectives
- To study and implement Discrete Fourier Transform (DFT) using MATLAB.
- To learn the analysis and synthesis of discrete-time signals using DFT and IDFT,
respectively.
Introduction
The discrete-time Fourier transform (DTFT) provides frequency-domain
representation of sequences. DTFT is a function of the continuous variable (), which is
defined for infinite-length sequences. This is impractical because it makes DTFT a
numerically incomputable transform.
Therefore, attention is turned to a numerically computable transform, obtained by
sampling DTFT in the frequency domain. When applied to finite-duration sequences, it
gives us a new transform called Discrete Fourier Transform (DFT), which is the ultimate
numerically computable Fourier transform.
The Discrete Fourier Transform of an N-point sequence is given by:
N 1
X (k ) x(n)WNnk , 0 k N 1 (1)
n 0
2
j
where W N e N . Note that X (k ) (which is the result of DFT) is also an N-point
sequence, where: 0 k N 1.
The inverse discrete Fourier transform (IDFT) of an N-point signal X (k ) is given by:
N 1
1
x ( n)
N
X (k )W
k 0
nk
N , 0 n N 1 (2)
X xWN (3)
1
x XWN , (4)
N
where WN and WN are the DFT matrix and its conjugate, respectively. The following
MATLAB functions are used to implement the above equations:
1
function [Xk] = dft(xn, N)
Experiment
1. For the sequence x(n) [1, 1, 1, 1] , use the following MATLAB commands to compute
DFT:
x = [1, 1, 1, 1]; N = 4;
X = dft(x, N);
magX = abs(X);
phaX = angle(X)*180/pi;
2. Plot the magnitude and phase of the DFT signal in step (1).
3. Apply zero-padding operation, which is a technique that allows us to sample at dense (or
finer) frequencies, to get an 8-point sequence. Then compute its DFT. Use the following
MATLAB commands:
x = [1, 1, 1, 1, zeros(1,4)]; N = 8;
X = dft(x, N);
magX = abs(X);
phaX = angle(X)*180/pi;
4. Plot the magnitude and phase of the 8-point DFT signal in step (3).
5. Treat x(n) in step (1) as a 16-point sequence by padding 12 zeros instead of 4 zeros. Plot
the magnitude and phase of the resulting 16-point DFT signal.
6. For the sequence: x(n) cos(0.48n) cos(0.52n) , use the following MATLAB
commands that determine the 10-point DFT of x(n) to obtain an estimate of its DTFT:
n = [0:1:99]; x = cos(0.48*pi*n)+cos(0.52*pi*n);
n1 = [0:1:9]; y1 = x(1:1:10);
subplot(2, 1, 1); stem(n1, y1);
2
title('signal x(n), 0 <= n <= 9');
xlabel('n');
Y1 = dft(y1, 10); magY1 = abs(Y1(1:1:6));
k1 = 0:1:5; w1 = 2*pi*k1/10;
subplot(2, 1, 2); plot(w1/pi, magY1);
title('DTFT Magnitude');
xlabel('Frequency in pi units');
7. Use the following commands that pad 90 zeros to x(n) in step (6) to obtain a dense
spectrum:
n2 = [0:1:99]; y2 = [x(1:1:10) zeros(1,90)];
subplot(2, 1, 1); stem(n2, y2);
title('signal x(n), 0 <= n <= 9 + 90 zeros');
xlabel('n');
Y2 = dft(y2, 100); magY2 = abs(Y2(1:1:51));
k2 = 0:1:50; w2 = 2*pi*k2/100;
subplot(2, 1, 2); plot(w2/pi, magY2);
title('DTFT Magnitude');
xlabel('Frequency in pi units');
8. Use the following commands to determine DTFT for the first 100 samples of x(n) :
subplot(2, 1, 1); stem(n, x);
title('signal x(n), 0 <= n <= 99');
xlabel('n');
X = dft(x, 100); magX = abs(X(1:1:51));
k = 0:1:50; w = 2*pi*k/100;
subplot(2, 1, 2); plot(w/pi, magX);
title('DTFT Magnitude');
xlabel('Frequency in pi units');
9. Use the following commands to synthesize the sequence x(n) using the Inverse Discrete
Fourier Transform (IDFT):
x1 = idft(X, 100);
subplot(2, 1, 2); stem(n, x1);
title('Synthesized x(n)');
xlabel('n');
Questions
1. How can you improve the spectrum density?
2. How can you improve the spectrum resolution?
3. What are the differences between DFT and IDFT?
4. What are the differences between DFT and DTFT?