You are on page 1of 3

FACULTY OF ELECTRONIC AND COMPUTER ENGINEERING

BENG 3761

ELECTRONIC ENGINEERING LAB 4

LAB SESSION 4

DISCRETE FOURIER TRANSFORM (DFT)

Prepared by:
Electronic Engineering Department, FKEKK
1.0 OBJECTIVES
1.1 To expose students to basic Z-transform methods involved in Digital Signal
Processing using MATLAB.
1.2 To perform Z-transform and inverse Z-transform analytically and with the aid of modern
tools.

2.0 LIST OF EQUIPMENTS AND COMPONENTS


2.1 MATLAB Software

3.0 THEORY

The discrete Fourier transform (DFT) is a sampled version of the DTFT, hence it is better suited for
numerical evaluation on computers.

Here X(k) is an N point DFT of x(n). Note that X(k) is a function of a discrete integer k, where k
ranges from 0 to N − 1.

4.0 PROCEDURE

4.1 Computing the DFT

1. We will now develop our own DFT functions to help our understanding of how the DFT comes
from the DTFT. Write your own Matlab function X = DFTeqn(x) to implement the DFT of
equation where x is an N point vector containing the values x [0], · · · , x [N – 1] and X is the
corresponding DFT. Your routine should implement the DFT exactly as specied by the DFT
−𝑗2𝜋𝑘𝑛
equation 𝑋 (𝑘) = ∑𝑁−1
𝑛=0 𝑥[𝑛]𝑒 𝑁 , using for-loops for n and k.

2. Test your routine DFTeqn by computing 𝑋(𝑘) for each of the following cases:
a. 𝑥[𝑛] = 𝛿[𝑛] for N = 10.
b. 𝑥[𝑛] = 1 for N = 10.
𝑗2𝜋𝑛
c. 𝑥[𝑛] = 𝑒 𝑁 for N = 10.
2𝜋𝑛
d. 𝑥[𝑛] = cos ( 10 ) for N = 10
Then, plot the magnitude of each of the DFT's.
3. Write a second Matlab function x = IDFTeqn(X) for computing the inverse DFT where X is the
N point vector containing the DFT and x is the corresponding time-domain signal. Use the
function IDFTeqn to invert each of the DFT's computed in the previous problem. Plot the
magnitudes of the inverted DFT's, and verify that those time-domain signals match the
original ones. Use abs(x) to eliminate any imaginary parts which round-off error may
produce.

4.2 Matrix Representation of the DFT

The DFT also can be implemented as a matrix-vector product. To see this, consider the equation
𝑿 = 𝑨𝒙
Where 𝑨 is an N ×N matrix, and both 𝑿 and 𝒙 are N ×1 column vectors. This matrix product is
equivalent to the summation
𝑁

𝑋(𝑘) = ∑ 𝐴𝑘𝑛 𝑥[𝑛],


𝑛=1
Where 𝐴𝑘𝑛 is the matrix element in the 𝑘 𝑡ℎ kth row and 𝑛𝑡ℎ column of A . By comparing both
−𝑗2𝜋(𝑘−1)(𝑛−1)
equation above we see that for the DFT, 𝐴𝑘𝑛 = 𝑒 𝑁 .
The numbers of “−1's” are in the exponent because MATLAB indices start at 1, not 0.

1. Write a Matlab function A = DFTmatrix(N) that returns the NxN DFT matrix A.

2. Use the matrix A to compute the DFT of the following signals. Confirm that the results are
the same as in the previous section 4.1.
a. 𝑥[𝑛] = 𝛿[𝑛] for N = 10.
b. 𝑥[𝑛] = 1 for N = 10.
𝑗2𝜋𝑛
c. 𝑥[𝑛] = 𝑒 𝑁 for N = 10.
Then, plot the magnitude of each of the DFT's.

3. As with the DFT, the inverse DFT may also be represented as a matrix-vector product.

𝒙 = 𝑩𝑿
a. Write an analytical expression for the elements of the inverse DFT matrix B
b. Write a Matlab function B = IDFTmatrix(N) that returns the NxN inverse DFT matrix.
c. Compute the matrices A and B for N = 5. Then compute the matrix product C = BA.
What form does C have? Why does it have this form? (student should print out the
matrices A, B and C.)

4. Compare your answer of DFTeqn(x) and DFTmatrix(N) with the build in MATLAB function
fft(x).

You might also like