KEMBAR78
DSP Lab Spring 23 Exp-05-06 | PDF | Discrete Fourier Transform | Harmonic Analysis
0% found this document useful (0 votes)
21 views8 pages

DSP Lab Spring 23 Exp-05-06

The document is a laboratory manual for a Digital Signal Processing course focusing on the Discrete Fourier Transform (DFT). It outlines learning objectives, required equipment, and various tasks involving DFT, FFT, and linear convolution using MATLAB. Additionally, it includes sections for student feedback and assessment criteria.

Uploaded by

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

DSP Lab Spring 23 Exp-05-06

The document is a laboratory manual for a Digital Signal Processing course focusing on the Discrete Fourier Transform (DFT). It outlines learning objectives, required equipment, and various tasks involving DFT, FFT, and linear convolution using MATLAB. Additionally, it includes sections for student feedback and assessment criteria.

Uploaded by

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

DIGITAL SIGNAL PROCESSING LAB

(EL-3031)
LABORATORY MANUAL

Discrete Fourir Transform(DFT)


(LAB # 05–06)
Student Name: ______________________________________________

Roll No: ________________ Section: ____

Date performed: _____________, 2023

____________________________________________________________________________________________________________________________________________________________

NATIONAL UNIVERSITY OF COMPUTER AND EMERGING SCIENCES, ISLAMABAD

Prepared by: Engr. Muhammad Asim


Last Edited by: Engr. Muhammad Asim, Feb 20, 2016
Verified by: Dr. Shahzad Saleem, Dr. Farhan Khalid Updated: Spring 2023
DSP - Lab National University Roll No: __________
05

Lab #
of Computer and Emerging Sciences
(EL3031) Islamabad Spring 2023
_____________________________________________________________________________________
Lab # 05-06: Discrete Fourier Transform
Learning Objectives
1) Introduction to DFT
2) DTFT vs DFT
3) FFT and IFFT
4) Observing relationship between k and f in Hz
5) Properties of DFT
6) Linear Convolution of two sequences using DFT

Equipment Required
1. PC
2. MATLAB

1. Introduction
Discrete Fourier Transform (DFT) is used for performing frequency analysis of discrete time signals. DFT
gives a discrete frequency domain representation whereas the other transforms are continuous in frequency
domain. The N point DFT of discrete time signal x[n] is given by the equation
N −1 − j 2 πkn
X ( k )= ∑ x [ n ] e N
; k =0 ,1 , 2 , … … … … … … … … … N−1
n=0

Where N is chosen such that N ≥ L , where L=length of x [n]. The inverse DFT allows us to recover the
sequence x[n] from the frequency samples.
N −1 j 2 πkn
1
x [n ]=
N
∑ X [k]e N
; n=0 , 1, 2 … … .. N −1
k=0

−j2π
Also the DFT operator W =e N is referred as twiddle factor.
N
X(k) is a complex number (remember e− jθ =cosθ− jsinθ ). It has both magnitude and phase which are
plotted versus k. These plots are magnitude and phase spectrum of x [n]. The ‘k’ gives us the frequency
information. Here k=N in the frequency domain corresponds to sampling frequency (fs). Increasing N,
increases the frequency resolution, i.e. it improves the spectral characteristics of the sequence. For
example if f s = 8kHz and N=8 point DFT, then in the resulting spectrum, k=1 corresponds to 1kHz
frequency. For the same f s and x[n], if N=80 point DFT is computed, then in the resulting spectrum, k=1
corresponds to 100Hz frequency. Hence, the resolution in frequency is increased. Since N ≥ L , increasing
N from 8 t o 80 for the same x[n] implies x[n] is still the same sequence (<8), the rest of x[n] is
padded with zeros. This implies that there is no further information in time domain, but the resulting
spectrum has higher frequency resolution. This spectrum is known as ‘high density spectrum’ (resulting
from zero padding x[n]). Instead of zero padding, for higher N, if more number of points of x[n] are taken
(more data in time domain), then the resulting spectrum is called a ‘high resolution spectrum’.
The discrete Fourier transform (DFT) X[k] of a finite-length sequence x[n] can be easily computed in
MATLAB using the function “fft” command. There are two versions of this function:
1) fft (x ) Computes the DFT X[k] of the sequence x[n] where the length of X[k] is the same as that of
_____________________________________________________________________________________________
Page 2 of 8
DSP - Lab National University Roll No: __________
05

Lab #
of Computer and Emerging Sciences
(EL3031) Islamabad Spring 2023
_____________________________________________________________________________________
x[n] which means N=L.
2) fft ( x , L) Computes the N-point DFT of a sequence x[n] of length L where N ≥ L. If N>L, x[n] is
zero-padded with N−L trailing zero-valued samples before the DFT is computed.
The inverse discrete Fourier transform (IDFT) x[n] of a DFT sequence X[k] can likewise be computed
using the function ifft, which also has two versions.

DTFT vs DFT
Task#01:
1) Generate a DT multi-tone sinusoidal sequence x [n] with f1=200Hz; f2=600Hz; f3=1300Hz and
sampling frequency and Fs=3000Hz.

x [ n ] =sin ( 2 πFsf n )+sin ( 2 πFsf n )+sin ( 2 πFsf n ) 0 ≤ n ≤31


1 2 3

2) Write a MATLAB program to compute the N-point DFT X[k] of sequence x[n] above
X =DN x While

3) Plot (Stem) the magnitude and phase spectrum of X[k] with respect to2 πk /N .
4) Compute the DTFT of x [n] by using [ X DTFT , w ] =freqz ( x)
5) Plot the X DTFT with respect to w on the same above figure of DFT using “line” command instead
of “plot” because plot and stem cannot work together.
6) Observe and comment on the sampling of DTFT.
7) Write a MATLAB program to compute and plot the N-point IDFT of X[k] by using following
−1 −1 1 ¿
formula x=D N X while D N = DN
N
¿
Hint: You can use the “conj” command to compute D N .
8) Plot the sequence x[n] obtained after taking IDFT.

FFT and IFFT


Task#02:
1) Write a matlab function to compute and plot the the N-point DFT and N-point IDFT of a
sequence (use x[n] from Task 1) using fft and ifft commands. The function should be of
following type
_____________________________________________________________________________________________
Page 3 of 8
DSP - Lab National University Roll No: __________
05

Lab #
of Computer and Emerging Sciences
(EL3031) Islamabad Spring 2023
_____________________________________________________________________________________
Function[ ]=DFT (n , x , N ) Where n shows indexes of x.
2) Run the program for different values of the DFT length N (use N = 32 and N = 64).

Observing relationship between k and f in Hz


Task#03:
1) Generate a DT sinusoidal sequence x [n] with f=900Hz, Fs=2000Hz and0 ≤ n ≤200 .
2) Compute its DFT with N=201 using “fft” and plot its magnitude and phase spectrum with respect
to k.
3) Check from the graph that which value of k is related to f=900Hz.
fN
4) Compute k for f=900Hz usingk = .
Fs

Verifying Circular Time Shift and Frequency Shifting Property of DFT


Task#04:
1) Generate a sinusoidal sequence g[n]=sin ( 2 π∗0.5∗n ) , n=0:7 ;
2) Write a matlab code to verify the circular time shift property of DFT of g[n] with
shift no=5.
g¿
3) Write a matlab code to verify the frequency shift property of DFT of g[n] with shift
ko = 5.
−k o n
WN g [ n ] DFT G ¿

Verifying N-point Circular convolution Property of DFT


Task#05:
By multiplying two N-point DFTs in the frequency domain, we get the circular
convolution in the time domain.
1) Generate two sinusoidal sequences
g[n]=sin ( 2 π∗0.5∗n 1 ) ,n 1=0 :6 ; h [n ]=sin ( 2 π∗0.3∗n 2 ) , n 2=0 :6 ;
2) Write a matlab code to verify the circular convolution property of DFT

g [ n ] =x [ n ]
Linear Convolution of two finite length sequences using DFT
Let g[n] and h[n] be two finite-length sequences of length N and M, respectively. We want to
compute the linear convolution of these sequences with L=N+M-1 using DFT then the corresponding
implementation scheme is illustrated below

_____________________________________________________________________________________________
Page 4 of 8
DSP - Lab National University Roll No: __________
05

Lab #
of Computer and Emerging Sciences
(EL3031) Islamabad Spring 2023
_____________________________________________________________________________________

Task#06:
1) Generate two sinusoidal sequences
g [ n ] =sin ( 2 π∗0.5∗n ) , n=0 :6 ; h[n]=cos ( 2 π∗0.3∗n ) , n=0 :9 ;
2) Compute and plot the linear convolution of above two signals using “conv”.
3) Now use the above mentioned scheme to compute and plot the linear convoltuion of
above two sequences.
4) Compare the results of above two methods and comment on these results.

_____________________________________________________________________________________________
Page 5 of 8
DSP - Lab National University Roll No: __________
05

Lab #
of Computer and Emerging Sciences
(EL3031) Islamabad Spring 2023
_____________________________________________________________________________________

Student's feedback: Purpose of feedback is to know the strengths and weaknesses of the system
for future improvements. This feedback is for the 'current lab session'. Circle your choice:

[-3 = Extremely Poor, -2 = Very Poor, -1 = Poor, 0 = Average, 1 = Good, 2 = Very Good, 3 = Excellent]:
The following table should describe your experience with:
S# Field Rating Describe in words if required
1 Overall Session -
-2 -1 0 1 2 3
3
2 Lab Instructor -
-2 -1 0 1 2 3
3
3 Lab Staff -
-2 -1 0 1 2 3
3
4 Equipment -
-2 -1 0 1 2 3
3
5 Atmosphere -
-2 -1 0 1 2 3
3

Any other valuable feedback: ______________________________________________________


______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________

Student's Signature: _________________________________


AWARDED

Correctness

Conclusion
Originality
of results

Initiative
Neatness
MARKS

Attitude

TOTAL

TOTAL 10 10 10 20 20 30 100

EARNED

Lab Instructor's Comments:________________________________________________________


_____________________________________________________________________________________________
Page 6 of 8
DSP - Lab National University Roll No: __________
05

Lab #
of Computer and Emerging Sciences
(EL3031) Islamabad Spring 2023
_____________________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________

Lab Instructor's Signature: _________________________________

_____________________________________________________________________________________________
Page 7 of 8
DSP - Lab National University Roll No: __________
05

Lab #
of Computer and Emerging Sciences
(EL3031) Islamabad Spring 2023
_____________________________________________________________________________________

Assessment Rubric
LLO Statement Assessment Exemplary Proficient Developing Beginning Worst
Method (20%) (20%) (20%) (20%) Performance
(20%)
1 Analysis of Practical Skill Able to attempt Able to attempt Able to attempt Able to attempt Able to attempt
discrete-time Observation complete lab with 80% of the lab 60% of the lab 40% of the lab 20% of the lab
signals and during proper tasks tasks tasks tasks
verifying their experimentati labeling/explanatio
properties i.e. on & Lab n of results and
Discrete Fourier Reports proper commenting
Transform of the code
(DFT), Discrete
Time Fourier
Transform
(DTFT) using
MATLAB.

_____________________________________________________________________________________________
Page 8 of 8

You might also like