0% found this document useful (0 votes)
2 views

Lab4_Report-2-2-2-2-2-1-9

Uploaded by

Prisha Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lab4_Report-2-2-2-2-2-1-9

Uploaded by

Prisha Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

ELL319 Digital Signal Processing

Lab Report | Experiment 4


Prisha Jain - 2021EE30330
Sanandh Kataria - 2021EE1

March 19, 2025

DFT, IDFT and FFT


1​ Objectives
Learning to compute N point Discrete Fourier Transform, and Inverse Discrete Fourier Trans- form
for a sequence for a sequence and to plot magnitude and phase spectrum. Using DFT and IDFT,
perform linear and circular convolution of two sequences. Also learning about Fast Fourier Transform
and its usefulness in finding the frequency spectrum of signals.

Part A:​ To write a C program to compute the N point complex valued DFT of an array x[n].

Part B:​ To write a C program to compute IDFT of a complex valued sequence X(k)

Part C:​ To implement the convolution operation in time domain.

Part D:​ To write a C function to compute the FFT of a sample domain signal x[n].

Part E:​ To compare the running time of FFT in Part D with the DFT function in Part A.

2​ Requirements:
1. CCS

3​ Theory
3.1​ Part A: Discrete Fourier Transform
The discrete Fourier Transform is used to find the amplitude and phase spectrum of a discrete time
sequence x[n] of length N as
N−1
X(k) = DFT (x[n]) =​ x[n]e−j2πkn/N​ ∀k ∈ {0, 1, · · · , N − 1}​ (1)
n=0

The real part of X(k) can be seen as the correlation between x and cosine function of frequency k and
the imaginary part as that between x and sine function of frequency k. Correlation between two
signals, by its very definition, can be seen as a metric of the similarity between the two signals. Closer
the frequencies of the two signals, higher the magnitude of correlation X(k) will
be. To get the frequencies in the signal, we require sampling frequency fs used to sample x[n]. The
frequencies in the signal are then given by
(2)
f = fs · k
N

3.2​ Part B: Inverse Discrete Fourier Transform


Given a frequency spectrum X(k), Inverse Discrete Fourier Transform is the inverse of the operation
given in equation (1). It yields the domain signal x[n] back. IDFT is given by

3.3​ Part C: Convolution of two signals using DFT and IDFT


Convolution of two signals x[n] and h[n] in time(or sample) domain is given by
N−1
y[n] =​ x[k]h[n − k]​ (4)
k=0

In frequency domain the convolution of the two signals corresponds to multiplication of the Fourier
transforms of the two signals, given by

Y (k) = X(k)H(k)​ (5)

where X(k) and H(k) are the Fourier transforms of x[n] and h[n] respectively.

3.4​ Part D: Fast Fourier Transform


The time complexity of the DFT computing algorithm is of quadratic in nature, i.e., O(n2) which gets
very inefficient in respect of large signals with a huge number of samples. Therefore we use Fast
Fourier Transforms, which are a class of algorithms that use divide and conquer strategy to compute
Fourier Transforms of smaller segments of the signal, and combine them to compute the overall
Fourier transform of the complete signal.

The most common type of algorithm used for Fast Fourier Transforms is the Radix-2 Dec- imation
In Time FFT. It assumes the signal size N to be a power of 2. Radix-2 DIT first computes the DFTs of
the even-indexed inputs (x2m = x0, x2, · · · xN−2) and of the odd indexed inputs (x2m+1 = x1, x3, · · ·
xN−1) and then combines the two results to produce the DFT of the whole sequence.

If we denote the DFT of the even indexed inputs x2m by Ek and the DFT of the odd indexed inputs x2m+1
by Ok, equation (6) above can be re-written as

X(k) = E(k) + e−2πjk/N O(k)​ (7)

Due to periodicity of the exponential, we can also simplify the expression for Xk+N/2 as

Xk+N/2 = E(k) − e−2πjk/N O(k)​ (8)


4​ Procedure
4.1​ Part A: Discrete Fourier Transform
•​ Equation (1) was modified using Euler’s theorem as:

N−1​ N−1

n=0​ n=0

•​ x[n] was taken in as an array and its complex valued Discrete Fourier Transform was calculated
using the above equation

4.2​ Part B: Inverse Discrete Fourier Transform


•​ Inverse Discrete Fourier Transform of the signal X(k) obtained in Part A is calculated using the
formula given in equation (3).
•​ IDFT yields sample domain signal x[n] back.

4.3​ Part C: Convolution


•​ In order to calculate the convolution of two signals x[n] and h[n], we first calculate the N -point
DFT of each of the signals in frequency domain, multiply the two as Y (k) = X(k)H(k) and
calculate the inverse DFT of Y(k) to obtain y[n].
•​ Both the signals x[n] of length L and h[n] of length K are made of length N = L + K − 1 and their
N -point DFT Y (k) is calculated.
•​ N -point IDFT of Y (k) is calculated to get back the convoluted signal y[n]

4.4​ Part D: Fast Fourier Transform


•​ Fast Fourier Transform is calculated using a recursive algorithm based on the equations (6), (7),
and (8).

4.5​ Part E: Execution Time for Part A and Part D


•​ The running times for each of the algorithms are analytically calculated with exceptions of
constants and henceforth compared.

5​ Code

Listing 1: Custom struct defined for handling complex numbers in header file complex.h
Listing 2: Implementation of complex.h

Listing 3: Code for Part A


Listing 4: Code for Part B
Listing 5: Code for Part C

Listing 6: Code for Part D


Listing 7: main function calling the other functions
6​ Graphs
6.1​ Part A

The graphs in Figure 1a show the Magnitude Response and Figure 1b shows the Phase Response of
the DFT X[k] of the signal input signal x[n].

(a)​ Magnitude Response

(b)​ Phase Response

Figure 1: DFT X[k] of input signal x[n]


6.2​ Part D

The graph in Figure 2a shows the Magnitude Response and Figure 2b shows the Phase Response of
the FFT X2[k] of the signal input signal x[n].

(a)​ Magnitude Response

(b)​ Phase Response

Figure 2: FFT X2[k] of input signal x[n]

You might also like