DSP Lab Spring 24 Exp-02
DSP Lab Spring 24 Exp-02
(EL-3031)
LABORATORY MANUAL
(LAB # 02)
Student Name: ______________________________________________
____________________________________________________________________________________________________________________________________________________________
Lab #
of Computer and Emerging Sciences
(EL3031) Islamabad Spring 2024
_____________________________________________________________________________________
Lab # 02: BASIC CONCEPTS OF DIGITAL SIGNAL PROCESSING
Learning Objectives
A. Relative Error
B. Circular Shift and Circular Time Reversal
C. Sequence Generation from Continuous Time Signals (Sampling)
D. Sampling Rate Alteration
Equipment Required
1. PC
2. MATLAB
Relative Error
Whenever a signal/sequence is corrupted by some noise then it is important to find the
difference between the original signal and the corrupted signal and this normalized
difference is called relative error. Relative error is defined as the ratio of the L2−norm of
the difference signal and the L2−norm of original signal {x [n]}.
Erel =¿ ¿
Where { y [n ]} is the corrupted sequence and {x [n]} is the original sequence.
Task 01:
1. Generate a sinusoidal sequence x [ n ] =sin (0.5∗pi∗n) −10< n≤ 10
2. Add noise to the above signal using command “awgn” to generate a signal y [ n ] . You can
use ‘help awgn’.
3. Find Relative error Erel using the above given formula.
4. Plot in time domain using ‘stem’.
Task 02:
1. Find frequency response of x [ n ] ∧ y [ n ] of Task 01 and plot these response with
respect to normalized digital angular frequency ω .
2. Use the ‘freqz’ command to find the frequency response.
Modulo Operation:
_____________________________________________________________________________________________
Page 2 of 7
DSP - Lab National University Roll No: __________
02
Lab #
of Computer and Emerging Sciences
(EL3031) Islamabad Spring 2024
_____________________________________________________________________________________
Let 0,1,………. N-1 be a set of N positive integers and let m be any integer. The integer r
obtained by evaluating m modulo N is called the residue. The residue r is an integer with a
value between 0 and N-1.
Circular Time Reversal:
The circular time-reversal version {y[n]} of a length-N sequence {x[n]} defined for
N−1 ≤ n ≤ 0 is given by { y [ n ] }={ x [ ⟨−n ⟩N ]} .
Circular Shift:
Let x[n] be a length-N sequence defined for N−1 ≤ n ≤ 0. Its circularly shifted version
x c [n] shifted by n0 samples is given by
{ x c [ n ] }={x [ ⟨ n−n0 ⟩ N ]}
Task 03:
1. Generate and plot the following exponential sequence
x [ n ] =0.5 ,−3< n ≤10
n
clc, clear;
f=1/4; % Frequency in Hz
Dt=0.01;
t=0:Dt:12; % sec
y_t = sin(2*pi*f*t);
%% Oversampling
%y_n=y_t(1:1/((2*f/Fs)*Dt):end);
fs=4*f;Ts1=1/fs;
n1=t(1)/Ts1:1:t(end)/Ts1;
y_n1=sin(2*pi*f*n1*Ts1);
_____________________________________________________________________________________________
Page 3 of 7
DSP - Lab National University Roll No: __________
02
Lab #
of Computer and Emerging Sciences
(EL3031) Islamabad Spring 2024
_____________________________________________________________________________________
%% Under sampling
fs=1.5*f;Ts2=1/fs;
n2=t(1)/Ts2:1:t(end)/Ts2;
y_n2=sin(2*pi*f*n2*Ts2);
%n=0:1/(2*f/Fs):12;
Task 05:
Generate a multi-tone sinusoidal signal with f 1=2000Hz and f2=4000Hz, then by sampling
generate the Oversampled and Undersampled version of it and display the frequency
response also.
Lab #
of Computer and Emerging Sciences
(EL3031) Islamabad Spring 2024
_____________________________________________________________________________________
Task 06:
1. Generate and plot the follwing sinusoidal sequence
x [ n ] =sin (2∗pi∗0.25∗n) −15< n≤ 20
2. Generate and plot x 1 [ n ] by upsampling the above sequence x [ n ] by 3.
3. Generate and plot x 2 [ n ] by downsampling the above sequence x [ n ] by 3.
4. Help: Use ‘upsample’ and ‘downsample ’commands
5. Now, generate and plot x 3 [ n ] by upsampling x 2 [ n ] by 3.
6. Now, generate and plot x 4 [ n ] by downsampling x 1 [ n ] by 3.
Question
Are x 3 [ n ] and x [ n ] similar? If Yes/No then Why?
Question
Are x 4 [ n ] and x [ n ] similar? If Yes/No the Why?
_____________________________________________________________________________________________
Page 5 of 7
DSP - Lab National University Roll No: __________
02
Lab #
of Computer and Emerging Sciences
(EL3031) Islamabad Spring 2024
_____________________________________________________________________________________
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
Correctness
Conclusion
Originality
of results
Initiative
Neatness
MARKS
Attitude
TOTAL
TOTAL 10 10 10 20 20 30 100
EARNED
_____________________________________________________________________________________________
Page 6 of 7
DSP - Lab National University Roll No: __________
02
Lab #
of Computer and Emerging Sciences
(EL3031) Islamabad Spring 2024
_____________________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
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 7 of 7