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

EC256 Lab Task3

The document outlines Lab 3 on Spectral Analysis, focusing on the Discrete Fourier Transform (DFT) as a linear transformation and its applications in spectral analysis. It includes problems related to computing DFT and Inverse DFT (IDFT) using matrix operations, generating signals, and analyzing their frequency components. Additionally, it covers the approximation of the Discrete Time Fourier Transform (DTFT) using DFT for a specific sequence.

Uploaded by

623128gcloud
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

EC256 Lab Task3

The document outlines Lab 3 on Spectral Analysis, focusing on the Discrete Fourier Transform (DFT) as a linear transformation and its applications in spectral analysis. It includes problems related to computing DFT and Inverse DFT (IDFT) using matrix operations, generating signals, and analyzing their frequency components. Additionally, it covers the approximation of the Discrete Time Fourier Transform (DTFT) using DFT for a specific sequence.

Uploaded by

623128gcloud
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Lab 3 : Spectral Analysis

V. Prakash Singh, PhD

Department of Electronics and Communication Engineering,


National Institute of Technology Andhra Pradesh,
Tadepalligudem, Andhra Pradesh
India

Jan 28, 2025


Problem 1: DFT as a Linear Transformation

Consider an N-point (length N) sequence x[n] and its N-point DFT


X [k] is written as column vectors

x = [x[0] x[1] · · · x[N − 2] x[N − 1]T


X = [X [0] X [1] · · · X [N − 2] X [N − 1]T

We can write the DFT and IDFT equations as Matrix operations


(linear transformation) as

X = WN x
−1 1 ∗
X = WN x= W x
N N

The N × N DFT matrix WN is a unitary matrix i.e. WN WN = NIN

V. Prakash Singh, PhD


Department of Electronics and Communication Engineering, National Institute of Technology Andhra Pradesh, Tadepalligudem, Andhra Pradesh India
Lab 3 : Spectral Analysis
Problem 1: DFT as a Linear Transformation

The N × N DFT matrix is given as

1 1 1 ··· 1
 
1 W 1
N W 2
N ··· WNN−1 
WN =  .. .. ..
 
.. 
. . . . 
2(N−1) N(N−1)
1 WNN−1 WN ··· WN

j 2π
where WN = e N is called the twiddle factor.

V. Prakash Singh, PhD


Department of Electronics and Communication Engineering, National Institute of Technology Andhra Pradesh, Tadepalligudem, Andhra Pradesh India
Lab 3 : Spectral Analysis
Problem 1: DFT as a Linear Transformation
(a) Write a function X = mydft(x, N) to compute the N-point DFT
coefficients of a sequence x of length L using the DFT matrix
approach. Assume L ≤ N. You may have to do zero-padding to make
the length of the sequence N.

(b) Generate a random sequence x of length 20 with x ∼ N (0, 1) and


compute the 32-point DFT coefficients using the function
implemented in (a). Compare the result with MATLAB function fft.
Use randn function to generate Gaussian distributed random
sequence.

(c) Write a function x = myidft(X ) to compute the N-point IDFT of a


sequence X of length N using the DFT matrix approach.

(d) Compute the IDFT of X obtained in (b) and compare the result with
sequence x.
V. Prakash Singh, PhD
Department of Electronics and Communication Engineering, National Institute of Technology Andhra Pradesh, Tadepalligudem, Andhra Pradesh India
Lab 3 : Spectral Analysis
Problem 2: Spectral Analysis Using DFT
Spectral analysis studies the frequency spectrum contained in discrete,
uniformly sampled data. The discrete Fourier transform (dft) is a tool
that reveals frequency components of a signal by representing it in
frequency space.

A plot of the power spectrum (power of DFT coefficients) is called a


periodogram. The first half of the principal frequency range (from 0
to the Nyquist frequency Fs /2 is sufficient, because the second half is
a reflection of the first half.

Spectra are often plotted with a principal frequency range from


Fs Fs
2 to 2 . You may use the MATLAB function fftshift to rearrange
the outputs of dft and zero-centered spectrum.

The list in the next slide shows the basic relationships among the
various quantities involved in any spectral analysis
V. Prakash Singh, PhD
Department of Electronics and Communication Engineering, National Institute of Technology Andhra Pradesh, Tadepalligudem, Andhra Pradesh India
Lab 3 : Spectral Analysis
Problem 2: Spectral Analysis Using DFT

Figure: Relationship between Parameters


V. Prakash Singh, PhD
Department of Electronics and Communication Engineering, National Institute of Technology Andhra Pradesh, Tadepalligudem, Andhra Pradesh India
Lab 3 : Spectral Analysis
Problem 2: Spectral Analysis Using DFT
(a) A pure tone of frequency f Hz is the sinusoidal signal
x(t) = A sin(2πft + ϕ). Here A is the amplitude of the tone, f is the
frequency in Hz, and ϕ is the phase. Generate a pure tone of 3
seconds duration at middle C (256 Hz in Western Musical Scale). Use
a sampling frequency 8 KHz. Let the amplitude be one and the phase
be zero, and plot N = 300 samples. Listen to the sound using sound
function in MATLAB.

(b) Create the C Major chord for duration 2 seconds by adding three
tones together of the notes C (261.63 Hz), E (329.63 Hz), and G
(392.00 Hz) with the same amplitudes A = 1. Listen to the result
using soundsc(to avoid clipping at ±1). Also, plot this signal.

(c) Find and sketch the power spectrum of the signal. Use appropriate
time and frequency ranges as in previous slide. Are you able to
identify each frequency present in the signal.
V. Prakash Singh, PhD
Department of Electronics and Communication Engineering, National Institute of Technology Andhra Pradesh, Tadepalligudem, Andhra Pradesh India
Lab 3 : Spectral Analysis
Problem 2: Spectral Analysis Using DFT
(a) Generate a signal for duration 1 seconds by adding two tones x1 and
x2 together of frequency 1 kHz and 5 KHz respectively. Add a
Gaussian noise with mean 0 and variance 0.01 to get a signal y . Use
sampling frequency of 44100 Hz. Compute and sketch the
log-magnitude spectrum 20 log(|Yk |) vs frequency in Hz.

(b) Generate a signal x = (x1 + x2 )2 where x1 and x2 are generated in (a).


Compute and sketch the log-magnitude spectrum 20 log(|Xk |) vs
frequency in Hz. Which frequency you can observe in the spectrum
and why ?

(c) Generate a signal x = (x1 + x2 ) where x1 is a tone of frequency 2


KHz and phase 0 and x2 is a tone of frequency 2 KHz and phase π/2.
Compute and sketch the log-magnitude spectrum 20 log(|Yk |) vs
frequency in Hz. Which frequency you can observe in the spectrum
and why ?
V. Prakash Singh, PhD
Department of Electronics and Communication Engineering, National Institute of Technology Andhra Pradesh, Tadepalligudem, Andhra Pradesh India
Lab 3 : Spectral Analysis
Problem 2: Spectral Analysis Using DFT

(d) Generate two signals x1 (t) and x2 (t) for duration 1 seconds as

x1 (t) = sin(2π5000t)
x2 (t) = x1 (t)e j2π2000t

Compute and sketch the log-magnitude spectrum of x1 (t) and x2 (t)


vs frequency in Hz in a single figure. Use hold function. What can
you infer from the plot ?

V. Prakash Singh, PhD


Department of Electronics and Communication Engineering, National Institute of Technology Andhra Pradesh, Tadepalligudem, Andhra Pradesh India
Lab 3 : Spectral Analysis
Problem 3: Approximation of DTFT using DFT

(a) We wish to compute the DTFT X (e jω ) of a finite length sequence


x[n] of length L = 30 at a single frequency ω = 18π/40. Design and
implement an algorithm to compute the DTFT at ω = 18π/40 using
DFT of x[n]. Use the DFT function implemented in problem 1 to find
the DFT. Write the pseudo-code of the algorithm in your answer
sheet. Consider the following function
(
2 when 0 ≤ n ≤ L − 1
x[n] =
0 otherwise

Derive the analytical expression of DTFT and evaluate at ω = 18π/40


and compare the result with that obtained from the above algorithm.

V. Prakash Singh, PhD


Department of Electronics and Communication Engineering, National Institute of Technology Andhra Pradesh, Tadepalligudem, Andhra Pradesh India
Lab 3 : Spectral Analysis

You might also like