SlideShare a Scribd company logo
1 of 100
1
DIGITAL SIGNAL PROCESSING
(3171003)
LABORATORY MANUAL
SEMESTER VII
DEPARTMENT OF
ELECTRONICS AND COMMUNICATION
ENGINEERING
GOVERNMENT ENGINEERING COLLEGE- MODASA
2
CERTIFICATE
This is to certify that Mr. Doshi Parth Dipeshkumar Enrolment no
200160111007 of the seventh semester of B.E has satisfactorily completed his
one full semester term work in “Digital Signal Processing (3171003)”
satisfactorily in partial fulfilment of Bachelor of Electronics and Communication
Engineering degree to be awarded by Gujarat Technological University.
Prof. Ketu Patel
Date: - …. /… /…….
3
Instructions for students:
1. The lab will meet every week.
2. Your activity, participation, and progress during the lab session will be part of your
lab grade.
3. A lab report for each will be due the following week in lab. Your lab report should
include relevant code fragments, figures, answers to questions in the quiz.
4. The lab consists of computer-based exercises. You are required to do programmingwith
MATLAB. Follow the guidelines for the usage of online Matlab simulator.
5. MATLAB tutorial can be downloaded for free from the Mathworks website:
http://www.mathworks.com/
6. Other documentation can be obtained at:
http://www.mathworks.com/access/helpdesk/help/helpdesk.shtml
7. Add your Matlab code and result in each experiment before taking printout.
4
Practical – Course Outcome Matrix
Sr.
No.
Objective(s) of Experiment
C
O
1
C
O
2
C
O
3
C
O
4
1.
Generation of elementary sequences in discrete-time
(i)unit impulse, (ii) unit step, (iii) unit ramp, (iv)
exponential,
(v)square, (vi) sin (vii) cosine,(viii) triangular,(ix) sinc signal
√
2.
Write a MATLAB program to implement time shifting and
time
reversal operation on discrete time sequences.
√
3.
Use help conv to find out how to use the conv
command.Let f(n) = u(n) − u(n − 4)
g(n) = n · u(n) − 2 (n − 4) · u(n − 4) + (n − 8) · u(n − 8).
Make stem plots of the following convolutions.
Use the MATLAB conv command to compute the convolutions.
(a) f(n) ∗ f(n)
(b) f(n) ∗ f(n) ∗ f(n)
(c) f(n) ∗ g(n)
(d) g(n) ∗ δ(n)
(e) g(n) ∗ g(n)
√
4.
Convolution of non-causal signals.
f(n) = 3 δ(n + 2) − δ(n − 1) + 2 δ(n − 3)
g(n) = u(n + 4) − u(n − 3)
x(n) = f(n) ∗ g(n)
√
5.
Suppose a system is implemented with the difference equation:
y(n) = x(n) + 0.5 x(n − 1)+ 2 x(n-2) − 0.95 y(n − 1)
Write your own MATLAB function, mysystem, to implement
thisdifference equation using a for loop.
(a) Is this system linear? Use your MATLAB function to
confirm your answer:
y1 = mysystem (x1)y2
= mysystem (x2)
y3 = mysystem (2*x1+3*x2)
Use any signals x1, x2 you like.
(b) Is this system time-invariant?
Confirm this in MATLAB (how?).
(c) Compute and plot the impulse response of this system.
√
5
Use x = [1, zeros(1,100)]; as input.
(d) Define x(n) = cos(π n/8) [u(n) − u(n − 50)]. Compute the output
of the system in two ways:
(1) y(n) = h(n) ∗ x(n) using the conv command.
(2) Use your function to find the output for this input signal. Are
the two output signals you compute the same?
6.
Write a MATLAB program to represent Moving average system
and
use it to compute the average of some sample values and to smooth
a noisy sequence.
√
7. Write a MATLAB program to generate impulse response and step
response of a system.
√
8.
Write a program to perform linear convolution of two sequences.
Get the input sequence and its duration form the user. Also plot all
the sequences.
√
9.
Write a program to find autocorrelation and cross correlation of
sequences. Verify auto correlation property to find energy of the
sequence and period of the sequence.
√
10. Write a program to compute DTFT of a sequence x[n]= (0.5)n u[n].
Plot its magnitude and phase response.
√
11. Write a program to demonstrate the time shifting and frequency
shifting property of DTFT.
√
12. Write a program to find Z transform and its inverse Z transform of
a
sequence Write a program to plot pole-zero of a given FIR/IIR
filter.
√
13. Write a program for Direct form – I,II form realization of the given
IIR system function.
√
14. Write a program to design digital FIR filter using various
windowing
technique.
√
15.
(A) Create Blackman Harris, Hamming and Gaussian window and
plot them in the same filter design tool.
(B) Design an FIR filter with side lobe attenuation of 40 dB using
Kaiser Window of 200 points.
√
16.
(A) Design low pass butter worth digital filter with given
specification using impulse invariance method.
(B) Design a high pass elliptical filter with given specification using
impulse invariance method.
(C) Design a band pass chebychev-2 filter with given specification
using impulse in-variance method.
√
6
17.
Design a second-order digital bandpass Butterworth filter with the
following specifications:
fu= 2.6 kHz,fL = 2.4 kHz , fs = 8000 Hz. Plot the magnitude and
phase response.
√
18. Write a program to compute N-point DFT of a given sequence.
Plot
its magnitude and phase response.
√
19. Write a program to perform circular convolution of two sequences
using DFT.
√
20. Write a program to perform linear convolution of two sequences
using DFT.
√
Rubrics for Assessment:
Index
(Progressive Assessment Sheet)
Sr.
No. Objective(s) of Experiment
Pag
eNo.
Date
of
perfo
r
mance
Date
of
subm
i
ssion
Asses
sment
Mark
s
Sign.
of
Teache
r with
date
Remar
ks
0. Mission & Vision
1.
Generation of elementary sequences in discrete-
time (i)unit impulse, (ii) unit step, (iii) unit
ramp, (iv)exponential, (v)square, (vi) sin (vii)
cosine,(viii)
triangular,(ix) sinc signal
2.
Write a MATLAB program to implement
tim
e
shifting and time reversal operation on discrete
Student Performance Evaluation
Punctuality
(2)
Active
Participation(2)
Accuracy
indata
collection,
analysis
etc.(2)
Submission
of
laboratory
file and
viva(2)
Professional
attitude,
behaviour(2)
Total
Marks
(10)
Assessment:
Full
Satisfactory
=2
Satisfactory =
1.5
Partially
satisfactory
=1
Not satisfactory
=0
7
timesequences.
3.
Use help conv to find out how to use the conv
command.
Let f(n) = u(n) − u(n − 4)
g(n) = n · u(n) − 2 (n − 4) · u(n − 4) + (n − 8) ·
u(n
− 8).
Make stem plots of the following
convolutions. Use the MATLAB conv
command to compute theconvolutions.
(a) f(n) ∗ f(n)
(b) f(n) ∗ f(n) ∗ f(n)
(c) f(n) ∗ g(n)
(d) g(n) ∗ δ(n)
(e) g(n) ∗ g(n)
4.
Convolution of non-causal signals.
f(n) = 3 δ(n + 2) − δ(n − 1) + 2 δ(n − 3)
g(n) = u(n + 4) − u(n − 3)
x(n) = f(n) ∗ g(n)
8
5.
Suppose a system is implemented with
thedifference equation:
y(n) = x(n) + 0.5 x(n − 1)+ 2 x(n-2) − 0.95 y(n
− 1)
Write your own MATLAB function,
mysystem, toimplement this difference
equation using a for loop.
(a) Is this system linear? Use your
Matlabfunction to confirm your answer:
y1 = mysystem (x1)
y2 = mysystem (x2)
y3 = mysystem (2*x1+3*x2)
Use any signals x1, x2 you like.
(b) Is this system time-invariant?
Confirm this in MATLAB (how?).
(c) Compute and plot the impulse response
of this system.
Use x = [1, zeros(1,100)]; as input.
(d) Define x(n) = cos(π n/8) [u(n) − u(n −
50)].
6.
Write a MATLAB program to represent Moving
average system and use it to compute the average of
some sample values and to smooth a noisy sequence.
7.
Write a MATLAB program to generate impulse
response and step response of a system.
8.
Write a program to perform linear convolution of
two sequences.
Get the input sequence and its duration form the
user. Also plot all the sequences.
9.
Write a program to find autocorrelation and cross
correlation of sequences. Verify auto correlation
property to find energy of the sequence and period
of the sequence.
10.
Write a program to compute DTFT of a sequence
x[n]= (0.5)n
u[n]. Plot its magnitude and phase
response.
11.
Write a program to demonstrate the time shifting
and frequency shifting property of DTFT.
9
12.
Write a program to find Z transform and its inverse
Z transform of a sequence Write a program to plot
pole-zero of a given FIR/IIR filter.
13.
Write a program for Direct form – I,II form
realization of the given IIR system function.
14.
Write a program to design digital FIR filter using
various windowing technique.
15.
(A) Create Blackman Harris, Hamming and
Gaussian window and plot them in the same filter
design tool.
(B) Design an FIR filter with side lobe attenuation
of 40 dB using Kaiser Window of 200 points.
16.
(A) Design low pass butter worth digital filter with
given specification using impulse invariance method.
(B) Design a high pass elliptical filter with given
specification using impulse invariance method.
(C)Design a band pass chebychev-2 filter with given
specification using impulse in-variance
method.
17.
Design a second-order digital bandpass Butterworth
filter with the following specifications: fu= 2.6 kHz,
fL = 2.4 kHz , fs = 8000 Hz. Plot the magnitude and
phase response.
18.
Write a program to compute N-point DFT of a given
sequence. Plot its magnitude and phase response.
19.
Write a program to perform circular convolution of
two sequences using DFT.
20.
Write a program to perform linear convolution of
two sequences using DFT.
Total
10
Directorate of Technical Education (DTE)
Vision
 To facilitate quality technical and professional education having relevance for both
industry and society, withmoral and ethical values, giving equal opportunity and
access, aiming to prepare globally competent technocrats.
Mission
 Quality technical and professional education with continuous improvement of all the
resources andpersonnel
 To promote conducive ecosystem for Academic, Industry, Research, Innovations and
Startups
 To provide affordable quality professional education with moral values, equal
opportunities, accessibilityand accountability
 To allocate competent and dedicated human resources and infrastructure to the
institutions for providingworld-class professional education to become a Global Leader
(“Vishwa Guru”)
Government Engineering College- Modasa
Vision
 To be a leading institution ensuring Academic Excellence, Research, Nurturing
Innovation and EntrepreneurialAttitude to produce competent technocrats for service
to Nation.
Mission
 To be a student centric institute imbibing experiential, innovative and lifelong
learning skills, addressingsocietal problems.
 To create a conducive ecosystem for Research, innovation & extension services.
 To inculcate entrepreneurial attitude and values amongst Learners.
 To Collaborate with Industries and other institutions to strengthen symbiotic relations.
 To mentor aspiring Institutions to unleash their potential, towards nation building.
Electronics and Communication Engineering Department
Vision
 To strive for academic excellence, enhance industry- institute interaction to create
competent technocrats inrelevant areas for addressing ever changing needs of society.
11
Mission
 To ensure dissemination of knowledge through effective teaching and learning
process.
 To strengthen collaboration with industries.
 To prepare the students with multidisciplinary competence for their successful career
and service to thesociety.
PO (Program outcomes):
Engineering Graduates will be able to
1. Engineering knowledge: Apply the knowledge of mathematics, science,
engineering fundamentals, and an engineering specialization to the solution of
complex engineering problems.
2. Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems
and design system components or processes that meet the specified needs with
appropriate consideration for the public healthand safety and the cultural, societal,
and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data,
and synthesis of the information to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineeringand IT tools including prediction and modeling to complex
engineering activities with an understanding ofthe limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of,
and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities
and norms of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large such as, being able to comprehend
and write effective reports anddesign documentation, make effective presentations,
and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a
member and leader in a team, to manage projects and in multidisciplinary
environments.
12
12. Life-long learning: Recognize the need for, and have the preparation and ability to
engage inindependent and life-long learning in the broadest context of technological
change.
Program Specific Outcomes:
 Employ domain knowledge of analog and digital electronics along with
communication systems in the design and implementation of application-oriented
engineering systems.
 Develop programming skills in assembly, embedded C, and HDL to effectively
address contemporaryand future challenges.
Course Outcomes (COs):
 Formulate engineering problems in terms of DSP tasks.
 Analyze digital and analog signals and systems.
 Analyze discrete time signals in frequency domain.
 Design digital filters
13
Practical: 1
Date:
Competency and Practical Skills: Introduction to the MATLAB technical computing
environment which involves the basic concepts of the language such as data types, operators
and control structures along with writing, executing and debugging Matlab code for various
tasks such as data analysis, visualization and simulation.
Data analysis, modeling, visualization, and build computational competence with MATLAB.
Relevant CO: Analyse digital and analog signals and systems
Objectives: Generation of elementary sequences in discrete- time
unit impulse, (ii) unit step, (iii) unit ramp, (iv) exponential, (v)square, (vi) sin (vii)cosine,(viii)
triangular,(ix) sinc signal
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory: Elementary signal plays a vital role in the study of signals and systems. It serves as
a basic building blocks for the construction of most complex signals. These elementary
signalsare also called standard signals.
(i) Unit Impulse 𝛿�(𝑛�) = { 1 𝑛� = 0 0 𝑛� ≠ 0
(ii) Unit Step 𝑢�(𝑛�) = { 1 ≥ 0 0 𝑛� < 0
(iii) Unit ramp 𝑟�(𝑛�) = { 𝑛� 𝑛� ≥ 0 0 𝑛� < 0
(iv) Exponential 𝑥�(𝑛�) = 𝑎�n 𝑓�𝑜�𝑟� 𝑎�𝑙�𝑙� 𝑛�
(v) Sinusoidal signal 𝑥�(𝑛�) = 𝐴� 𝑠�𝑖�𝑛�(𝑤�𝑛� + ∅)
(vi) Cosine signal 𝑥�(𝑛�) = 𝐴� 𝑐�𝑜�𝑠�(𝑤�𝑛� + ∅)
Write a script: In the main menu of Matlab, select file -> new -> M-file A new window will
pop up. Type in your commands and then save the file with the .m extension under the default
path matlab/work.
Using the Matlab help system, click on
Help -> MATLAB help or type helpdesk to open the help files. For a description of a single
function or command, type
help command_name on the command line, or use ’search’ in the help window. For example,
type
14
help plot or help clc or help sinc
Be aware that Matlab is case sensitive i.e. vectors ‘a’ and ‘A’ are different.
Suggested MATLAB function:
1. exp()
2. sin()
3. cos()
4. square()
5. tripuls()
6. subplot()
7. stem()
8. title()
9. xlabel()
10. ylabel()
11. figure()
MATLAB Code:
clc;
clear all;
close all;
figure('Name', 'Signal Plots - Figure 1', 'NumberTitle', 'off');
% Signal 1: Unit Impulse
n = 0:4;
a = zeros(size(n));
a(1) = 1;
subplot(2, 1, 1);
stem(n, a, 'filled', 'y', 'LineWidth', 1.5);
grid on;
title('Unit Impulse');xlabel('Samples');ylabel('Amplitude');
% Signal 2: Unit Step
n = 0:4;
a = ones(size(n));
subplot(2, 1, 2);
stem(n, a, 'filled', 'b', 'LineWidth', 1.5);
grid on;
title('Unit Step');xlabel('Samples');ylabel('Amplitude');
figure('Name', 'Signal Plots - Figure 2', 'NumberTitle', 'off');
15
% Signal 3: Unit Ramp
n = 0:4;
a = n;
subplot(2, 1, 1);
stem(n, a, 'filled', 'r', 'LineWidth', 1.5);
grid on;
title('Unit Ramp');xlabel('Samples');ylabel('Amplitude');
% Signal 4: Exponential
n = 0:0.5:2.5;
a = exp(n);
subplot(2, 1, 2);
stem(n, a, 'g', 'LineWidth', 1.5);
grid on;
title('Exponential');xlabel('Samples');ylabel('Amplitude');
figure('Name', 'Signal Plots - Figure 3', 'NumberTitle', 'off');
% Signal 5: Random Signal
a = rand(1, 5);
subplot(2, 1, 1);
stem(a, 'filled', 'm', 'LineWidth', 1.5);
grid on;
title('Random Signal');xlabel('Samples');ylabel('Amplitude');
% Signal 6: Square Wave
n = 0:0.002:(1/30);
a = square(2*pi*30*n);
subplot(2, 1, 2);
stem(n, a, 'filled', 'b', 'LineWidth', 1.5);
grid on;
title('Square Wave');xlabel('Time (s)');ylabel('Amplitude');
figure('Name', 'Signal Plots - Figure 4', 'NumberTitle', 'off');
% Signal 7: Sine Wave
a = sin(2*pi*30*n);
subplot(2, 1, 1);
stem(n, a, 'filled', 'c', 'LineWidth', 1.5);
grid on;
title('Sine Wave');xlabel('Time (s)');ylabel('Amplitude');
% Signal 8: Cosine Wave
a = cos(2*pi*30*n);
subplot(2, 1, 2);
stem(n, a, 'filled', 'k', 'LineWidth', 1.5);
grid on;
title('Cosine Wave');xlabel('Time (s)');ylabel('Amplitude');
figure('Name', 'Signal Plots - Figure 5', 'NumberTitle', 'off');
% Signal 9: Sinc Function
n = linspace(-5, 5, 25);
a = sinc(n);
subplot(2, 1, 1);
stem(n, a, 'filled','y', 'LineWidth', 1.5);
grid on;
title('Sinc Function');xlabel('Samples');ylabel('Amplitude');
16
Output:
% Signal 10: Triangular Pulse
n = -2:0.5:2;
a = tripuls(n, 4);
subplot(2, 1, 2);
stem(n, a, 'filled', 'b', 'LineWidth', 1.5);
grid on;
title('Triangular Pulse');xlabel('Samples');ylabel('Amplitude');
17
18
19
Quiz:
1. A discrete-time signal is shown in the figure:
Sketch and label each of the following signals
 x[n-2]
 x[4-n]
 x[2n]
 x[n]u[2-n]
 x[n-1]δ[n-3]
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete-Time Signal Processing”: Oppenheim, Schafer, Buck Pearson
education publication, 2nd Edition, 2003.
References used by the students:
Rubric-wise marks obtained:
Rubrics 1 2 3 4 5 Total
Marks
Faculty Sign:
20
Practical: 2
Date:
Competency and Practical Skills: Introduction to the MATLAB technical computing
environment which involves the basic concepts of the language such as data types, operators
and control structures along with writing, executing and debugging Matlab code for various
tasks such as data analysis, visualization and simulation.
Relevant CO: Analyse digital and analog signals and systems
Objectives: Write a matlab program to implement time shifting and time reversal operation
on discrete time sequences.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
Time shifting:
Time shifting operation of a discrete-time signal x(n) can be represented by
y(n) = x(n-k)
The signal y(n) can be obtained by time shifting the signal x(n) by k units. If k is positive, it
is delay and the shift is to the right, and if k is negative, it is advance and the shift is to the
left.
Time Reversal:
The time reversal, also called the folding of a signal x(n) can be obtained by folding the signal
about n = 0. This operation is very useful in convolution. It is denoted by x(-n). It is obtained
by replacing the independent variable n by (–n).
21
Suggested MATLAB function:
fliplr()
iinput()
MATLAB Code:
clc;
clear all;
close all;
n1 = input('Enter the amount to be delayed: ');
n2 = input('Enter the amount to be advanced: ');
n = -2:2;
x = [-2, 3, 0, 1, 5];
% Original Signal
subplot(3, 1, 1);
stem(n, x, 'b', 'filled', 'LineWidth', 1.5);
title('Signal x(n)');xlabel('n');ylabel('Amplitude');
% Delayed Signal x(n-n1)
m = n + n1;
y = x;
subplot(3, 1, 2);
stem(m, y, 'r', 'filled', 'LineWidth', 1.5);
title(['Delayed Signal x(n-', num2str(n1), ')']);
xlabel('n');ylabel('Amplitude');
% Advanced Signal x(n+n2)
t = n - n2;
z = x;
subplot(3, 1, 3);
stem(t, z, 'g', 'filled', 'LineWidth', 1.5);
title(['Advanced Signal x(n+', num2str(n2), ')']);
xlabel('n');ylabel('Amplitude');
figure;
% Original Signal x(n)
n = -1:2;
x = [3, -1, 0, -4];
subplot(2, 1, 1);
stem(n, x, 'b', 'filled', 'LineWidth', 1.5);
axis([-3, 3, -5, 5]);
title('Signal x(n)');xlabel('n');ylabel('Amplitude');
22
Output:
% Reversed Signal x(-n)
c = fliplr(x);
y = -fliplr(n);
subplot(2, 1, 2);
stem(y, c, 'r', 'filled', 'LineWidth', 1.5);
axis([-3, 3, -5, 5]);
title('Reversed Signal x(-n)');xlabel('n');ylabel('Amplitude');
23
Quiz:
1. Sketch the following signals.
(i) 𝑢�(−𝑡� + 2)
(ii) 2 𝑟�(𝑡� − 2)
(iii) 𝑢�(𝑡� + 3)𝑢�(−𝑡� + 3)
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer, Buck
Pearsoneducation publication, 2nd Edition, 2003.
References used by the students:
24
Rubric wise marks obtained:
Rubrics 1 2 3 4 5 Total
Marks
Faculty Sign:
25
Practical: 3
Date:
Competency and Practical Skills: Introduction to the MATLAB technical computing
environment which involves the basic concepts of the language such as data types, operators
and control structures along with writing, executing and debugging Matlab code for various
tasks such as data analysis, visualization and simulation.
Relevant CO: Analyse digital and analog signals and systems
Objectives: Use help conv to find out how to use the conv command.Let
f(n) = u(n) − u(n − 4)
g(n) = n · u(n) − 2 (n − 4) · u(n − 4) + (n − 8) · u(n − 8).
Make stem plots of the following convolutions.
Use the MATLAB conv command to compute the convolutions.
1. f(n) ∗ f(n)
2. f(n) ∗ f(n) ∗ f(n)
3. f(n) ∗ g(n)
4. g(n) ∗ δ(n)
5. g(n) ∗ g(n
Comment on your observations.
What happens as you repeatedly convolve this signal with itself? Use the commands title,
xlabel, ylabel to label the axes of your plots.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
Convolution: Convolution is a mathematical operation which is used to express the input-
output relationship of an LTI system. It relates the input and impulse response of the system
to output. The convolution of two signals x(n) and h(n) can be represented as:
𝑦�(𝑛�)�=�𝑥�(𝑛�)�∗�ℎ(𝑛�)�=�ℎ(𝑛�)�∗�𝑥�(𝑛�)
26
𝑦(𝑛)�=� ∑ 𝑥(𝑘)ℎ(𝑛 − 𝑘)
∞
𝑘�=�0
�=� ∑ ℎ(𝑘𝑥(𝑛 − 𝑘)
∞
𝑘�=�0
Suggested MATLAB function:
1. conv()
2. deconv()
MATLAB Code:
clc;
clear all;
close all;
% Define the sequences f(n) and g(n)
n = 0:15;
f = (n >= 0) - (n >= 4);
g = n.*(n >= 0) - 2*(n-4).*(n >= 4) + (n-8).*(n >= 8);
% (a) Compute and plot f(n) * f(n)
conv_ff = conv(f, f);
subplot(3, 2, 1);
stem(conv_ff, 'y', 'LineWidth', 1.5);
title('f(n) * f(n)');
xlabel('n');
ylabel('Amplitude');
% (b) Compute and plot f(n) * f(n) * f(n)
conv_fff = conv(conv_ff, f);
subplot(3, 2, 2);
stem(conv_fff, 'b', 'LineWidth', 1.5);
title('f(n) * f(n) * f(n)');
xlabel('n');
ylabel('Amplitude');
% (c) Compute and plot f(n) * g(n)
conv_fg = conv(f, g);
subplot(3, 2, 3);
stem(conv_fg, 'g', 'LineWidth', 1.5);
title('f(n) * g(n)');
xlabel('n');
ylabel('Amplitude');
% (d) Compute and plot g(n) * δ(n)
delta = [1, zeros(1, length(n)-1)]; % Delta function
conv_g_delta = conv(g, delta);
subplot(3, 2, 4);
stem(conv_g_delta, 'r', 'LineWidth', 1.5);
title('g(n) * δ(n)');
xlabel('n');
ylabel('Amplitude');
27
Output:
Quiz:
1. Find output of the system with impulse response h(n) = {1, 2, 3,4}, n = -1:2 for an
input
x(n) = {1,1,1,1}, n=0:3.
2
. Perform linear convolution of following signals using graphical method.
h(n) = u(n)-u(n-N) where N is an positive integer
x(n)= an
u(n)
% (e) Compute and plot g(n) * g(n)
conv_gg = conv(g, g);
subplot(3, 2, 5);
stem(conv_gg, 'c', 'LineWidth', 1.5);
title('g(n) * g(n)');
xlabel('n');
ylabel('Amplitude');
28
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
29
Practical-4
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Analyse digital and analog signals and systems
Objectives: Convolution of non-causal signals.
 f(n) = 3 δ(n+2) – δ(n-1) + 2δ(n-3)
 g(n) = u(n+4) – u(n-3)
 x(n) = f(n) ∗ g(n)
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
Convolution: Convolution is a mathematical operation which is used to express the input-
output relationship of an LTI system. It relates the input and impulse response of the system
to output. The convolution of two signals x(n) and h(n) can be represented as:
𝑦�(𝑛�) = 𝑥�(𝑛�) ∗ ℎ(𝑛�) = ℎ(𝑛�) ∗ 𝑥�(𝑛�)
∞ ∞
𝑦�(𝑛�) = Σ 𝑥�(𝑘�) ℎ(𝑛� − 𝑘�) = Σ ℎ(𝑘�)𝑥�(𝑛� − 𝑘�)
k= –∞ k= –∞
Suggested MATLAB function:
 conv()
 deconv()
Comment on your observations.
Use the commands title, xlabel, ylabel to label the axes of your plots.
30
MATLAB Code:
Output:
clc;
clear all;
close all;
% Define the discrete signals f(n) and g(n)
n = -10:10; % Define a suitable range for n
f = [0, 0, 3, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; % Values
of f(n) extended to cover the appropriate range
g = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; % Values
of g(n)
% Compute the convolution x(n) = f(n) * g(n)
x = conv(f, g, 'same'); % 'same' option for keeping the output length the same
as input
% Plot the results
subplot(3, 1, 1);
stem(n, f, 'r', 'filled'); % Plot f(n) in red
xlabel('n');
ylabel('f(n)');
title('Signal f(n)');
subplot(3, 1, 2);
stem(n, g, 'b', 'filled'); % Plot g(n) in blue
xlabel('n');
ylabel('g(n)');
title('Signal g(n)');
subplot(3, 1, 3);
stem(n, x, 'g', 'filled'); % Plot x(n) in green
xlabel('n');
ylabel('x(n)');
title('Convolution x(n) = f(n) * g(n)');
% Adjust the plot layout for better visualization
sgtitle('Convolution of Non-Causal Signals');
% Display the plot
grid on;
31
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
32
Practical-5
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Formulate engineering problems in terms of DSP tasks
Objectives: Suppose a system is implemented with the difference equation:
y(n) = x(n) + 0.5 x(n − 1)+ 2 x(n-2) − 0.95 y(n − 1)
Write your own Matlab function, mysystem, to implement this difference equation using a
for loop.If the input signal is N-samples long (0 ≤ n ≤ N − 1), your program should find the
first N sample of the output y(n) (0 ≤ n ≤ N − 1).
a) Is this system linear? Use your Matlab function to confirm your answer:
 y1 = mysystem (x1)
 y2 = mysystem (x2)
 y3 = mysystem (2*x1+3*x2)
 Use any signals x1, x2 you like.
b) Is this system time-invariant?Confirm this in Matlab.
c) Compute and plot the impulse response of this system.Use x = [1, zeros(1,100)]; as
input.
d) Define x(n) = cos(π n/8) [u(n) − u(n − 50)].
Compute the output of the system in two ways: (1) y(n) = h(n) ∗ x(n) using the conv command.
(2) Use your function to find the output for this input signal. Are the two outputsignals you
compute the same?
Equipment/Instruments: MATLAB 2021a with Signal Processing Toolbox
Theory:
Linear System:
Asystem which obeys the principle of superposition and homogeneity is called a linear system,
and a system which does not obey the principle of superposition and homogeneity is called a
non-linear system.
33
Homogeneity principle means system which produces an output y(n) for an input x(n) must
produce an output ay(n) for an input ax(n).
Superposition principle means a system which produces an output y1(n) for an input x1(n) and
an output y2(n) for an input x2(n) must produce an output y1(n)+ y2(n) for an input x1(n)
+x2(n).
𝑇�[𝑎�𝑥�1(𝑛�) + 𝑏�𝑥�2(𝑛�)] = 𝑎�𝑇�[𝑥�1(𝑛�)] + 𝑏�𝑇�[𝑥�2(𝑛�)]
Time-invariant System:
A system is said to be time-invariant (or shift-invariant) if its input/output characteristics does
not change with time, i.e. a shift in the input results in a corresponding time shift in the output.
Let x(n) be the input and let x(n-k) be the input delayed by k units.
y(n) = T[x(n)] be the output for the input x(n).
y(n,k) = T[x(n-k)] be the output for the delayed input.
y(n-k) = y(n)|n=n-k be the output delayed by k units.
Impulse Response of the System:
Response of a system to an impulse input is called as impulse response of the system. It is
denoted by h(n).
h(n) = T [δ(n)]
An LTI system is completely characterized by its impulse response.
Suggested MATLAB function:
a) function
b) for
c) input()
d) impz()
MATLAB Code:
Objective A:
34
clc;
clear all;
close all;
% Define the difference equation implementation
N = 100; % Length of signals
n = 0:N-1;
x1 = rand(1, N); % Random signal 1
x2 = rand(1, N); % Random signal 2
x3 = 2 * x1 + 3 * x2; % Combined signal
y1 = zeros(1, N);
y2 = zeros(1, N);
y3 = zeros(1, N);
for k = 1:N
if k == 1
y1(k) = x1(k);
y2(k) = x2(k);
y3(k) = 2 * x1(k) + 3 * x2(k);
elseif k == 2
y1(k) = x1(k) + 0.5 * x1(k - 1);
y2(k) = x2(k) + 0.5 * x2(k - 1);
y3(k) = 2 * x1(k) + 3 * x2(k) + 0.5 * (2 * x1(k - 1) + 3 * x2(k -
1));
else
y1(k) = x1(k) + 0.5 * x1(k - 1) + 2 * x1(k - 2) - 0.95 * y1(k - 1);
y2(k) = x2(k) + 0.5 * x2(k - 1) + 2 * x2(k - 2) - 0.95 * y2(k - 1);
y3(k) = 2 * x1(k) + 3 * x2(k) + 0.5 * (2 * x1(k - 1) + 3 * x2(k - 1))
+ 2 * (2 * x1(k - 2) + 3 * x2(k - 2)) - 0.95 * (2 * y1(k - 1) + 3 * y2(k -
1));
end
end
% Check linearity
if isequal(y3, y1 + 2 * y2)
disp('The system is linear.');
else
disp('The system is not linear.');
end
% Plot the results
subplot(3, 1, 1);
stem(n, y1, 'b', 'LineWidth',2);
title('y1 = mysystem(x1)');
xlabel('n');
ylabel('Amplitude');
subplot(3, 1, 2);
stem(n, y2, 'g', 'LineWidth',2);
title('y2 = mysystem(x2)');
xlabel('n');
ylabel('Amplitude');
subplot(3, 1, 3);
stem(n, y3, 'r', 'LineWidth',2);
title('y3 = mysystem(2*x1 + 3*x2)');
xlabel('n');
ylabel('Amplitude');
35
Output:
Objective B:
clc;
clear all;
close all;
% Define the difference equation implementation
N = 100; % Length of signals
n = 0:N-1;
x1 = rand(1, N); % Random signal 1
x2 = rand(1, N); % Random signal 2
y1 = zeros(1, N);
y2 = zeros(1, N);
36
Output:
% Define a time shift amount
k = 5; % Shift amount
% Shift the input signals
x1_shifted = circshift(x1, [0, k]);
x2_shifted = circshift(x2, [0, k]);
% Recompute the outputs with the shifted inputs
y1_shifted = zeros(1, N);
y2_shifted = zeros(1, N);
y3_shifted = zeros(1, N);
for m = 1:N
if m == 1
y1_shifted(m) = x1_shifted(m);
y2_shifted(m) = x2_shifted(m);
y3_shifted(m) = 2 * x1_shifted(m) + 3 * x2_shifted(m);
elseif m == 2
y1_shifted(m) = x1_shifted(m) + 0.5 * x1_shifted(m - 1);
y2_shifted(m) = x2_shifted(m) + 0.5 * x2_shifted(m - 1);
y3_shifted(m) = 2 * x1_shifted(m) + 3 * x2_shifted(m) + 0.5 * (2 *
x1_shifted(m - 1) + 3 * x2_shifted(m - 1));
else
y1_shifted(m) = x1_shifted(m) + 0.5 * x1_shifted(m - 1) + 2 *
x1_shifted(m - 2) - 0.95 * y1_shifted(m - 1);
y2_shifted(m) = x2_shifted(m) + 0.5 * x2_shifted(m - 1) + 2 *
x2_shifted(m - 2) - 0.95 * y2_shifted(m - 1);
y3_shifted(m) = 2 * x1_shifted(m) + 3 * x2_shifted(m) + 0.5 * (2 *
x1_shifted(m - 1) + 3 * x2_shifted(m - 1)) + 2 * (2 * x1_shifted(m - 2) + 3
* x2_shifted(m - 2)) - 0.95 * (2 * y1_shifted(m - 1) + 3 * y2_shifted(m -
1));
end
end
% Check if the system is time-invariant
if isequal(y1_shifted, y1) && isequal(y2_shifted, y2) &&
isequal(y3_shifted, y3)
disp('The system is time-invariant.');
else
disp('The system is not time-invariant.');
end
37
Objective C:
Output:
clc;
clear all;
close all;
% Define the impulse input x
x_impulse = [1, zeros(1, 100)];
% Initialize the impulse response signal
h_impulse = zeros(size(x_impulse));
% Compute the impulse response using the difference equation
for k = 1:length(x_impulse)
if k == 1
h_impulse(k) = x_impulse(k);
elseif k == 2
h_impulse(k) = x_impulse(k) + 0.5 * x_impulse(k - 1);
else
h_impulse(k) = x_impulse(k) + 0.5 * x_impulse(k - 1) + 2 * x_impulse(k
- 2) - 0.95 * h_impulse(k - 1);
end
end
% Plot the impulse response
stem(0:length(h_impulse) - 1, h_impulse, 'g', 'LineWidth',2);
title('Impulse Response');
xlabel('n');
ylabel('Amplitude');
38
Objective D:
Output:
clc;
clear all;
close all;
% Define the impulse input x
x_impulse = [1, zeros(1, 100)];
% Initialize the impulse response signal
h_impulse = zeros(size(x_impulse));
% Define x(n) = cos(π n/8) [u(n) − u(n − 50)]
n = 0:150; % Adjust the length to accommodate the signal
x_cosine = cos(pi * n / 8) .* (n >= 0 & n <= 50);
% (1) Compute output using the conv command
y_conv = conv(x_cosine, h_impulse, 'same');
% (2) Compute output using the implemented system
y_mysystem = zeros(size(x_cosine));
for k = 1:length(x_cosine)
if k == 1
y_mysystem(k) = x_cosine(k);
elseif k == 2
y_mysystem(k) = x_cosine(k) + 0.5 * x_cosine(k - 1);
else
y_mysystem(k) = x_cosine(k) + 0.5 * x_cosine(k - 1) + 2 * x_cosine(k -
2) - 0.95 * y_mysystem(k - 1);
end
end
% Compare the two output signals
if isequal(y_conv, y_mysystem)
disp('The two output signals are the same.');
else
disp('The two output signals are not the same.');
end
% Plot the output signals
subplot(2, 1, 1);
stem(n, y_conv);
title('Output using conv');
subplot(2, 1, 2);
stem(n, y_mysystem);
title('Output using mysystem');
39
Quiz:
I. For each of the following system determine whether the systems is 1) stable 2)causal
3) linear 4) time invariant 5) memoryless
a. 𝑇�{𝑥�(𝑛�)} = 𝑔�(𝑛�). 𝑥�(𝑛�) 𝑤�𝑖�𝑡�ℎ 𝑔�𝑖�𝑣�𝑒�𝑛� 𝑔�(𝑛�)
b. 𝑇�{𝑥�(𝑛�)} = ∑ 𝑥(𝑘)
𝑛
𝑘=𝑛0
c. 𝑇�{𝑥�(𝑛�)} = ∑ 𝑥(𝑘)
𝑘=𝑛+𝑛0
𝑘=𝑛−𝑛0
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
40
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
41
Practical-6
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Formulate engineering problems in terms of DSP tasks
Objectives: Write a matlab program to represent Moving average system and use it to
compute the average of some sample values and to smooth a noisy sequence.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
Signal Smoothing or Averaging is the Fundamental Noise Reduction Tool in 1-D Signal
Processing Such as a Monotonic Signal, Speech or Voice. Moving Average Filter is a Finite
Impulse Response (FIR) Filter smoothing filter used for smoothing the signal from short term
overshoots or noisy fluctuations and helps in retaining the true signal representation or retaining
sharp step response. It is a simple yet elegant statistical tool for de-noising signals in the time
domain.
The general moving average system is defined by
Suggested MATLAB function:
 rand()
 zeros()
 ones()
42
MATLAB Code:
Output:
clc;
clear all;
close all;
% Generate a sample noisy signal (you can replace this with your data)
t = linspace(0, 1, 100); % Time vector
noisy_signal = sin(2*pi*5*t) + 0.5*randn(1, 100); % Noisy sine wave
% Define the window size (number of samples to average)
window_size = 5;
% Create a moving average filter kernel (rectangular window)
ma_filter = ones(1, window_size) / window_size;
% Apply the moving average filter to the noisy signal
smoothed_signal = conv(noisy_signal, ma_filter, 'same');
% Compute the average of the noisy signal
signal_average = mean(noisy_signal);
% Plot the original noisy signal, smoothed signal, and the average
subplot(3,1,1);
plot(t, noisy_signal, 'b', 'LineWidth', 1.5);
title('Noisy Signal');
xlabel('Time');
ylabel('Amplitude');
subplot(3,1,2);
plot(t, smoothed_signal, 'b', 'LineWidth', 1.5);
title('Smoothed Signal (Moving Average)');
xlabel('Time');
ylabel('Amplitude');
subplot(3,1,3);
plot([0, 1], [signal_average, signal_average], 'r', 'LineWidth', 1.5);
title('Signal Average');
xlabel('Time');
ylabel('Average Value');
% Display the average value
fprintf('Signal Average: %.4fn', signal_average);
43
Quiz:
1. Find the impulse response of a Moving average system.
2. Check whether the moving average systems is 1) stable 2) causal 3) linear 4) time
invariant 5) memoryless
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
44
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
45
Practical-7
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence
with MATLAB.
Relevant CO: Analyse digital and analog signals and systems
Objectives: Write a matlab program to generate impulse response and step response of a
system.
Equipment/Instruments: MATLAB 2021a with Signal Processing Toolbox
Theory:
Impulse Response:
Response of a system to an impulse input is called as impulse response of the system. It is
denoted by h(n).
h(n) = T [δ(n)]
An LTI system is completely characterized by its impulse response. We can check causality,
stability of a system from its impulse response. Whether the system is FIR or IIR can also be
checked from the length of its impulse response.
Step Response:
Output of the system for a unit step input is called as step response of the system. It is
denoted by s(n). Unit step response can be obtained by convolving u(n) with the impulse
response h(n) of the system.
s(n) = T [u(n)]
s(n) =u(n) * h(n)
Suggested MATLAB function:
 filter()
 impz()
 ones()
 zeros()
46
MATLAB Code:
Output:
clc;
clear all;
close all;
% Define the system's transfer function (example: 1/(s^2 + 2s + 2))
numerator = 1;
denominator = [1, 2, 2];
% Compute the impulse response
impulse_response = impz(numerator, denominator);
% Generate the step response
step_response = cumsum(impulse_response);
% Time vector for plotting
t = 0:length(impulse_response) - 1;
% Plot the impulse response
subplot(2, 1, 1);
stem(t, impulse_response, 'r', 'LineWidth', 1.5);
title('Impulse Response');
xlabel('Time');
ylabel('Amplitude');
% Plot the step response
subplot(2, 1, 2);
plot(t, step_response, 'b', 'LineWidth', 1.5);
title('Step Response');
xlabel('Time');
ylabel('Amplitude');
47
Quiz:
1. Determine impulse response for each of the following system.
a) Moving Average System
b) Ideal Delay System
c) Accumulator System
d) Forward difference system
e) Backward difference system
f) Up-sampler system
g) Down-sampler system
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
48
Practical-8
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Formulate engineering problems in terms of DSP tasks
Objectives: Write a program to compute convolution of two sequences. Get the input
sequence and its duration from the user. Also plot all the sequences.
Check the range of convolved signal. If first sequence has range from -2:2 and second
sequence has range from 0:3, then convolved signal has range from -2:5.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Suggested Matlab functions:
 input()
 length()
 error()
 conv()
 deconv()
MATLAB Code:
clc;
clear all;
close all;
% Objective 1: Compute convolution of two sequences and plot them.
% Get the input sequence and its duration from the user
seq1 = input('Enter the first sequence: ');
seq2 = input('Enter the second sequence: ');
% Check if the lengths of the sequences are the same
if length(seq1) ~= length(seq2)
error('Input sequences must have the same length.');
end
% Compute the convolution of the sequences
convolved_seq = conv(seq1, seq2);
49
Output:
% Plot the input sequences and the convolved sequence
subplot(3, 1, 1);
stem(1:length(seq1), seq1, 'b', 'filled', 'LineWidth', 2);
title('First Sequence');
xlabel('Time');
ylabel('Amplitude');
subplot(3, 1, 2);
stem(1:length(seq2), seq2, 'r', 'filled', 'LineWidth', 2);
title('Second Sequence');
xlabel('Time');
ylabel('Amplitude');
subplot(3, 1, 3);
stem(1:length(convolved_seq), convolved_seq, 'g', 'filled', 'LineWidth', 2);
title('Convolved Sequence');
xlabel('Time');
ylabel('Amplitude');
% Objective 2: Check the range of the convolved signal
range_convolved = min(convolved_seq):max(convolved_seq);
fprintf('Range of convolved signal: %d:%dn', range_convolved(1),
range_convolved(end));
50
Command Window Input and output :
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
51
Practical-9
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Formulate engineering problems in terms of DSP tasks
Objectives: Write a program to find autocorrelation and cross correlation of sequences. Verify
auto correlation property to find energy of the sequence and period of the sequence.
Equipment/Instruments: MATLAB 2021a with Signal Processing Toolbox
Theory:
Cross Correlation: The cross correlation between two different waveforms or signals is a
measure of similarity or match or relatedness or coherence between one signal and the time
delayed version of another signal. This means the cross correlation between two signals
indicates how much one signal is related to the time delayed version of another signal.
A measure of similarity between a pair of energy signals x(n) and y(n) is given by cross
correlation.
∞
𝑟�xy(𝑘�) = Σ 𝑥�(𝑛�)𝑦�(𝑛� − 𝑘�) 𝑘� = 0, ±1, ±2 …
n= –∞
Autocorrelation: The autocorrelation gives the measure of match or similarity or relatedness or
coherence between a signal and its time delayed version. This means that the autocorrelatin function is
a special form of cross correlation function.
∞
𝑟�xx(𝑘�) = Σ 𝑥�(𝑛�)𝑥�(𝑛� − 𝑘�) 𝑘� = 0, ±1, ±2 …
n= –∞
The value of the autocorrelation function of a signal at origin (i.e. at k =0) is equal to the
energy of the signal i.e.
∞
𝑟�xx(0) = Σ 𝑥�(𝑛�)2 = 𝐸�x
n= –∞
52
Suggested Matlab functions:
 xcorr()
 findpeaks()
 diff()
 mean()
MATLAB Code:
clc;
clear all;
close all;
% Example input sequences
x = [1, 2, 1, 2, 1];
y = [2, 1, 2, 1, 2];
% Compute the autocorrelation of sequence x
autocorrelation_x = xcorr(x, x, 'biased');
% Compute the energy of sequence x using the autocorrelation property
energy_x = sum(x.^2);
% Find the period of sequence x using the autocorrelation property
period_x = find(autocorrelation_x == max(autocorrelation_x));
% Compute the cross-correlation between sequences x and y
crosscorrelation_xy = xcorr(x, y, 'biased');
% Compute the energy of sequence y using the autocorrelation property
energy_y = sum(y.^2);
% Find the period of sequence y using the autocorrelation property
period_y = find(autocorrelation_x == max(autocorrelation_x));
% Display results
fprintf('Autocorrelation of sequence x: n');
disp(autocorrelation_x);
fprintf('Energy of sequence x: %.4fn', energy_x);
fprintf('Period of sequence x: %dn', abs(period_x - length(x) + 1));
fprintf('Cross-correlation between sequences x and y: n');
disp(crosscorrelation_xy);
fprintf('Energy of sequence y: %.4fn', energy_y);
fprintf('Period of sequence y: %dn', abs(period_y - length(y)+1));
53
Output:
Quiz:
1
. Find the autocorrelation of the signal
x(n)= {1,2,4,6}, n = 0:3
2. Determine cross correlation of the signals
x(n)= {1,2,3}, n = 0:2 and y(n) = {4,1, -2.5} n = 0:2
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
54
Practical-10
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence
with MATLAB.
Relevant CO: Analyse discrete time signals in frequency domain
Objectives: Write a program to compute DTFT of a sequence x(n)= 0.5n
u(n). Plot its
magnitude and phase response.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
Discrete-Time Fourier Transform
The Fourier transform of a discrete-time sequence is known as the discrete-time Fourier
transform (DTFT).
Mathematically, the discrete-time Fourier transform (DTFT) of a discrete-timesequence x(n)
is defined as −
∞
𝑋�(𝜔�) = Σ 𝑥�(𝑛�)𝑒�–jωn
n= –∞
Suggested MATLAB function:
 angle()
 abs()
 plot()
MATLAB Code:
clc;
clear all;
close all;
55
Output:
% Define the sequence x[n]
n = 0:100; % Define a range of values for n
x = (0.5).^n .* (n >= 0); % Define x[n] using the unit step function u[n]
% Compute the DTFT
N = length(n); % Length of the sequence
w = linspace(0, 2*pi, N); % Angular frequencies from 0 to 2*pi
X = fft(x, N); % Compute the FFT of x[n]
% Plot the magnitude response
subplot(2, 1, 1);
plot(w, abs(X), 'b', 'LineWidth', 1.5);
title('Magnitude Response (DTFT)');
xlabel('Frequency (radians/sample)');
ylabel('Magnitude');
grid on;
% Plot the phase response
subplot(2, 1, 2);
plot(w, angle(X), 'g', 'LineWidth', 1.5);
title('Phase Response (DTFT)');
xlabel('Frequency (radians/sample)');
ylabel('Phase (radians)');
grid on;
% Adjust the plot layout
sgtitle('DTFT Analysis of x[n] = (0.5)^n u[n]');
56
Quiz:
1. Find the frequency response H(ejw
) of the LTI system whose input and output
satisfythe difference equation
𝑦(𝑛)��−��
1
2
�𝑦(𝑛 − 1)�= �𝑥(𝑛)�− �2𝑥(𝑛 − 1)�+ �𝑥(𝑛 − 2)
2. Write a difference equation that characterizes a system when frequency responseis
𝐻(𝑒𝑗𝑤
)�=�
1� −�
1
2
𝑒𝑗𝑤
�+�𝑒−𝑗3𝑤
1� −�
1
2
𝑒𝑗𝑤 �+�
3
4
𝑒−𝑗2𝑤
3. Find
 𝑋�(𝑒�j0)
 𝑋�(𝑒�jπ)
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
57
Practical-11
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Analyse discrete time signals in frequency domain
Objectives: Write a program to demonstrate the time shifting and frequency shiftingproperty
of DTFT.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
Discrete-Time Fourier Transform
The Fourier transform of a discrete-time sequence is known as the discrete-time Fourier
transform (DTFT).
Mathematically, the discrete-time Fourier transform (DTFT) of a discrete-timesequence x(n)
is defined as −
∞
𝑿�(𝝎�) = Σ 𝒙�(𝒏�)𝒆�–𝒋�𝝎�𝒏�
�����𝒏�= –∞
Time Shifting Property of Discrete-Time Fourier Transform
Statement - The time-shifting property of discrete-time Fourier transform states that if a
signal x(n) is shifted by k in time domain, then its DTFT is multiplied by 𝑒�–jωk.
Therefore, if
𝒙�(𝒏�) ↔ 𝑿�(𝝎�)
Then
𝑥�(𝑛� − 𝑘�) ↔ 𝑒�–jωk𝑋�(𝜔�)
Where, k is an integer.
58
Suggested MATLAB function:
 rand()
 fftshift()
 abs()
 plot()
MATLAB Code:
clc;
clear all;
close all;
% Define parameters
N = 256; % Number of samples
n = 0:N-1; % Time index
fs = 1000; % Sampling frequency (Hz)
t = n / fs; % Time vector (seconds)
% Original signal
x = cos(2*pi*100*t); % A cosine signal with a frequency of 100 Hz
% Time-shifted signal
delay_samples = 50; % Number of samples to delay by
x_shifted = zeros(1, N);
x_shifted(1+delay_samples:N) = x(1:N-delay_samples);
% Frequency-shifted signal
frequency_shift = 50; % Frequency shift in Hz
x_freq_shifted = x .* exp(1j*2*pi*frequency_shift*t);
% Compute the DTFT of each signal
X = fft(x, N);
X_shifted = fft(x_shifted, N);
X_freq_shifted = fft(x_freq_shifted, N);
% Frequency vector
frequencies = (0:N-1) * fs / N;
% Plot original signal
subplot(3, 1, 1);
plot(t, x, 'b', 'LineWidth', 1.5);
title('Original Signal (100 Hz)');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
% Plot time-shifted signal
subplot(3, 1, 2);
plot(t, x_shifted, 'r', 'LineWidth', 1.5);
title('Time-Shifted Signal (50 Samples)');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
59
% Plot frequency-shifted signal
subplot(3, 1, 3);
plot(t, real(x_freq_shifted), 'g', 'LineWidth', 1.5);
title('Frequency-Shifted Signal (50 Hz)');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
% Plot the magnitude spectra of all signals
figure;
subplot(3, 1, 1);
plot(frequencies, abs(X), 'b', 'LineWidth', 1.5);
title('Magnitude Spectrum of Original Signal');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid on;
subplot(3, 1, 2);
plot(frequencies, abs(X_shifted), 'r', 'LineWidth', 1.5);
title('Magnitude Spectrum of Time-Shifted Signal');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid on;
subplot(3, 1, 3);
plot(frequencies, abs(X_freq_shifted), 'g', 'LineWidth', 1.5);
title('Magnitude Spectrum of Frequency-Shifted Signal');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid on;
sgtitle('Time and Frequency Shifting Properties of DTFT');
60
Output:
61
Quiz:
1. Prove following properties of DTFT.
 Time shifting
 Frequency Shifting
2. Find Fourier Transform of 𝑥�(𝑛�) = 𝑎�n𝑢�(𝑛� − 5)
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
62
Practical-12
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Analyse discrete time signals in frequency domain
Objectives: Write a program to find Z transform and its inverse Z transform of a sequence.
Write a program to plot pole-zero of a given FIR/IIR filter.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
The Z-transform (ZT) is a mathematical tool which is used to convert the difference equations
in time domain into the algebraic equations in z-domain.
The Z-transform is a very useful tool in the analysis of a linear shift invariant (LSI) system.
An LSI discrete time system is represented by difference equations. To solve these difference
equations which are in time domain, they are converted first into algebraic equations in z-
domain using the Z-transform, then the algebraic equations are manipulated in z-domain and
the result obtained is converted back into time domain using the inverse Z-transform.
Mathematically, if x(n) is a discrete-time signal or sequence, then its bilateral or two-sided Z-
transform is defined as −
∞
𝑋�(𝑍�) = Σ 𝑥�(𝑛�)𝑍�–n; 𝑍� = 𝑟� 𝑒�jω
n= –∞
Region of Convergence (ROC) of Z-Transform
The set of points in the z-plane, for which the Z-transform of a discrete-time sequence x(n),
that is X(z) converges is called the region of convergence (ROC) of the Z-transform X(z).
For any given discrete-time sequence, the Z-transform may or may not converge. If there is no
point in the z-plane for which the function X(z) converges, then the sequence x(n) is said
tobe having no z-transform.
63
Suggested MATLAB function:
 ztrans()
 iztrans ()
 zplane()
MATLAB Code:
clc;
clear all;
close all;
% Input sequence (replace this with your sequence)
sequence = [1, 2, 3, 4, 5];
% Create a symbolic variable
syms z;
syms n; % Add a symbolic variable for the discrete-time index
% Compute the Z-transform manually
N = length(sequence);
z_transform = 0;
for n = 0:N-1
z_transform = z_transform + sequence(n+1) * z^(-n);
end
% Compute the inverse Z-transform manually
inverse_z_transform = iztrans(z_transform, n);
% Display the results
disp('Original Sequence:');
disp(sequence);
disp('Z-transform:');
disp(simplify(z_transform));
disp('Inverse Z-transform:');
disp(simplify(inverse_z_transform));
64
Output:
Quiz:
1. Find the inverse z-transform of the following.
𝐻(𝑧)�=�
1�+�2𝑧−1�+𝑧−2�
1−
3
2
𝑧−1�+�
1
2
𝑧−1
for all possible ROCs
2. Find the z-transform of followings.
𝑥�(𝑛�) = 𝑛� 𝑎�n 𝑢�(𝑛�) where 𝑥�(𝑛�) = {
𝑎𝑛
o, otherwise
𝑎𝑛
�= �0 ≤ 𝑛 ≤ 𝑁 − 1
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
65
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
66
Practical-13
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Analyse discrete time signals in frequency domain
Objectives: Write a program for Direct form – I,II form realization of the given IIR system
function.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
Direct-Form-I implementation of a 2nd-order digital filter.
The DF-I structure has the following properties:
1. It can be regarded as a zero filter section followed in series by a pole filter section.
2. In most fixed-point arithmetic schemes (such as two's complement, the most
commonly used) there is no possibility of internal filter overflow. That is, since there
is fundamentally only one summation point in the filter, and since fixed-point overflow
naturally “wraps around” from the largest positive to the largest negative number and
vice versa, then as long as the final result y(n) is “in range”, overflow is avoided, even
when there is overflow of intermediate results in the sum. This is an important, valuable,
and unusual property of the DF-I filter structure
67
3. There are twice as many delays as are necessary. As a result, the DF-I structure is not
canonical with respect to delay. In general, it is always possible to implement a Nth
order filter using only N delay elements.
4. As is the case with all direct-form filter structures (those which have coefficients given
by the transfer-function coefficients), the filter poles and zeros can be very sensitive to
round-off errors in the filter coefficients. This is usually not a problem for a simple
second-order section, but it can become a problem for higher order direct-form filters.
This is the same numerical sensitivity that polynomial roots have with respect to
polynomial-coefficient round-off. As is well known, the sensitivity tends to be larger
when the roots are clustered closely together, as opposed to being well spread out in
the complex plane. To minimize this sensitivity, it is common to factor filter transfer
functions into series and/or parallel second-order sections.
Direct-Form-II implementation of a 2nd-order digital filter.
The DF-II structure has the following properties:
1. It can be regarded as a pole filter section followed by a zero filter section.
2. It is canonical with respect to delay. This happens because delay elements associated
with the pole and zero sections are shared.
3. In fixed-point arithmetic, internal overflow can occur at the delay-line input (output of
the leftmost summer in the figure, unlike in the DF-I implementation, which can only
overflow if the output overflows.
4. As with all direct-form filter structures, the poles and zeros are sensitive to round-off errors in
the coefficients, especially for high transfer-function orders. Lower sensitivity is
obtained using series low-order sections (e.g., second order), or by using ladder or
lattice filter structures.
68
MATLAB Code:
Output:
clc;
clear all;
close all;
% Define the filter coefficients (replace with your own values)
b = [1, 0.5, 0.25];
a = [1, -0.6, 0.1];
% Define the input signal (replace with your own signal)
x = randn(1, 100);
% Implement Direct Form I realization
y_direct_form_I = filter(b, a, x);
% Implement Direct Form II realization
y_direct_form_II = filter(b, a, x);
% Plot the input and output signals
subplot(3, 1, 1);
plot(x, 'b', 'LineWidth', 1.5);
title('Input Signal');
subplot(3, 1, 2);
plot(y_direct_form_I, 'g', 'LineWidth', 1.5);
title('Direct Form I Output');
subplot(3, 1, 3);
plot(y_direct_form_II, 'r', 'LineWidth', 1.5);
title('Direct Form II Output');
69
Quiz:
1. Obtain the direct form II and parallel structures for the system
𝑦(𝑛)�=�
3
4
𝑦(𝑛 − 1)�−�
1
8
𝑦(𝑛 − 2)�+ �𝑥(𝑛)�+�
1
3
𝑥(𝑛 − 1)
2. Obtain the direct and cascade structure for the system function
𝐻�(𝑧�) = (1 + 0.25𝑧�–1 + 𝑧�–2)(1 + 0.5𝑧�–1 + 𝑧�–2)
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
70
Practical-14
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Design digital filters
Objectives: Write a program to design digital FIR filter using various windowing technique.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
An ideal low-pass filter has infinite attenuation in the stop-band. When we approximate an
ideal filter with a practical filter using the window method, we accept some approximation
error. The peak approximation error depends on the window type and is known for each
window as reported in Table:
Suggested MATLAB function:
 fir1()
 freqz ()
 bartlett()
 kaiser()
71
MATLAB Code:
Output:
clc;
clear all;
close all;
% Define filter specifications
fs = 1000; % Sampling frequency (Hz)
N = 101; % Filter order (odd)
fc = 100; % Cutoff frequency (Hz)
% Design the filter using different windowing techniques
% Rectangular Window
rectangular_window = ones(1, N);
rectangular_filter = fir1(N-1, fc/(fs/2), rectangular_window);
% Hamming Window
hamming_window = hamming(N);
hamming_filter = fir1(N-1, fc/(fs/2), hamming_window);
% Kaiser Window
kaiser_window = kaiser(N, 5); % The third argument (beta) determines the shape
of the window.
kaiser_filter = fir1(N-1, fc/(fs/2), kaiser_window);
% Frequency response plots
freqz(rectangular_filter, 1, 1024, fs);
title('Frequency Response (Rectangular Window)');
figure;
freqz(hamming_filter, 1, 1024, fs);
title('Frequency Response (Hamming Window)');
figure;
freqz(kaiser_filter, 1, 1024, fs);
title('Frequency Response (Kaiser Window)');
72
73
Quiz:
1. Design a low pass FIR filter with rectangular window with M=7.
𝐻𝑑(𝑤)�=�{
𝑒−3𝑗𝑤
0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑤𝑒
|𝑤|�≤�𝑤𝑐
Wc is 1 rad/sec
2. Write a short note on designing of FIR filter using windowing method.
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
74
References used by the students:
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
75
Practical-15
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Design digital filters
Objectives:
A) Create Blackman-Harris, Hamming and Gaussian window and plot them in the same filter
design tool.
(B) Design an FIR filter with side lobe attenuation of 40 dB using Kaiser Window of 200
points.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
Blackman window
The Blackman window exhibits an even lower maximum stopband ripple (about 74 dB down)
in the resulting FIR filter than the Hamming window. It is defined mathematically as
𝑤(𝑛)�= �0.42� − �0.5𝑐𝑜𝑠(2𝜋𝑛/𝑁 − 1)�+ �0.08𝑐𝑜𝑠(
4𝜋𝑛
𝑁
− 1) n = 0,1,2…….N-1
Hamming window
The Hamming window coefficients are given by the following formula:
𝑤(𝑛)�= �0.54� − �0.46𝑐𝑜𝑠(
2𝜋𝑛
𝑁
− 1) n = 0,1,2……N-1
Gaussian window
The coefficients of a Gaussian window are computed from the following equation:
W(n) = 𝑒
−1�𝑛
2(𝑎(𝐿−1)/2
2
where –(L – 1)/2 ≤ n ≤ (L – 1)/2, and α is inversely proportional to the standard deviation, σ,
of a Gaussian random variable. The exact correspondence with the standard deviation of a
Gaussian probability density function is σ = (L – 1)/(2α).
76
Suggested MATLAB function:
 blackman()
 hamming()
 zplane
MATLAB Code:
Objective A:
clc;
clear all;
close all;
% Define the length of the windows
window_length = 200;
% Create Blackman-Harris window
blackman_harris_window = blackmanharris(window_length);
% Create Hamming window
hamming_window = hamming(window_length);
% Create Gaussian window
sigma = 0.4; % Adjust sigma as needed
gaussian_window = gausswin(window_length, sigma);
% Plot the windows
figure;
subplot(3, 1, 1);
plot(blackman_harris_window);
title('Blackman-Harris Window', 'b', 'LineWidth', 1.5);
xlabel('Sample Index');
ylabel('Amplitude');
subplot(3, 1, 2);
plot(hamming_window, 'r', 'LineWidth', 1.5);
title('Hamming Window');
xlabel('Sample Index');
ylabel('Amplitude');
subplot(3, 1, 3);
plot(gaussian_window, 'g', 'LineWidth', 1.5);
title('Gaussian Window');
xlabel('Sample Index');
ylabel('Amplitude');
sgtitle('Window Functions');
77
Output:
Objective B:
clc;
clear all;
close all;
% Filter specifications
fs = 1000; % Sampling frequency (Hz)
fpass = 100; % Passband frequency (Hz)
fstop = 200; % Stopband frequency (Hz)
delta_p = 0.01; % Passband ripple
delta_s = 10^(-40/20); % Stopband attenuation (40 dB)
% Calculate the required filter order using Kaiser formula
A = -20*log10(min(delta_p, delta_s));
N = ceil((A - 8) / (2.285*(fstop - fpass) / fs));
% Design the FIR filter using Kaiser Window
kaiser_window = kaiser(N+1, A);
% Calculate the filter coefficients
filter_coeffs = fir1(N, fstop/(fs/2), 'low', kaiser_window);
% Plot the frequency response of the designed filter
freqz(filter_coeffs, 1, 1024, fs);
78
Output:
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
% Set the plot title and labels
title('Frequency Response of Kaiser Window FIR Filter');
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
79
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
80
Practical-16
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Design digital filters
Objectives:
 Design low pass butter worth digital filter with given specification usingimpulse
invariance method.
 Design a high pass elliptical filter with given specification using impulse invariance
method.
 Design a band pass chebychev-2 filter with given specification using impulse in-
variancemethod.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
81
Suggested MATLAB function:
 butter()
 ellip()
 cheby2()
MATLAB Code:
Objective A:
Output:
clc;
clear all;
close all;
% Filter specifications
fs = 1000; % Sampling frequency (Hz)
fpass = 100; % Passband frequency (Hz)
Ap = 1; % Passband ripple (dB)
order = 6; % Filter order
% Calculate the analog cutoff frequency
analog_cutoff_freq = 2 * fs * tan(pi * fpass / fs);
% Design the analog Butterworth filter
[b, a] = butter(order, analog_cutoff_freq, 's');
% Convert the analog filter to a digital filter using impulse invariance
[num, den] = impinvar(b, a, fs);
% Plot the frequency response of the designed filter
freqz(num, den, 1024, fs);
title('Frequency Response of Low-Pass Butterworth Filter');
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
82
Objective B:
clc;
clear all;
close all;
% Filter specifications
fs = 1000; % Sampling frequency (Hz)
fstop = 100; % Stopband frequency (Hz)
As = 40; % Stopband attenuation (dB)
Ap = 1; % Passband ripple (dB)
% Calculate the analog cutoff frequency
analog_cutoff_freq = 2 * pi * fstop / fs;
% Design the elliptical digital filter with Wn as a one-element vector
[N, Wn] = ellipord(analog_cutoff_freq/(2*pi), analog_cutoff_freq*1.2/(2*pi),
Ap, As);
[b, a] = ellip(N, Ap, As, Wn, 'high');
% Plot the frequency response of the designed high-pass elliptical filter
freqz(b, a, 1024, fs);
title('Frequency Response of High-Pass Elliptical Filter');
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
83
Output:
Objective C:
clc;
clear all;
close all;
% Filter specifications
fs = 1000; % Sampling frequency (Hz)
fpass1 = 80; % Lower passband frequency (Hz)
fpass2 = 120; % Upper passband frequency (Hz)
As = 40; % Stopband attenuation (dB)
order = 10; % Filter order
% Calculate the analog cutoff frequencies
analog_cutoff_freq1 = 2 * fs * tan(pi * fpass1 / fs);
analog_cutoff_freq2 = 2 * fs * tan(pi * fpass2 / fs);
% Design the analog Chebyshev-II filter
[b, a] = cheby2(order, As, [analog_cutoff_freq1, analog_cutoff_freq2], 's');
% Convert the analog filter to a digital filter using impulse invariance
[num, den] = impinvar(b, a, fs);
% Plot the frequency response of the designed filter
freqz(num, den, 1024, fs);
title('Frequency Response of Band-Pass Chebyshev-II Filter');
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
84
Output:
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
85
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
86
Practical-17
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Design digital filters
Objectives: Design a second-order digital bandpass Butterworth filter with the following
specifications: fu= 2.6 kHz,fL = 2.4 kHz , fs = 8000 Hz. Plot the magnitude and phase
response.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
Suggested MATLAB function:
 butter()
 freqs()
MATLAB Code:
87
Output:
clc;
clear all;
close all;
% Filter specifications
fs = 8000; % Sampling frequency (Hz)
fu = 2600; % Upper band edge frequency (Hz)
fL = 2400; % Lower band edge frequency (Hz)
order = 2; % Filter order (second-order)
% Normalize the frequencies
fu_normalized = fu / (fs/2);
fL_normalized = fL / (fs/2);
% Design the digital Butterworth bandpass filter
[b, a] = butter(order, [fL_normalized, fu_normalized], 'bandpass');
% Plot the frequency response of the designed filter
freqz(b, a, 1024, fs);
% Set plot titles and labels
title('Magnitude and Phase Response of Butterworth Bandpass Filter');
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB) / Phase (radians)');
% Show grid on the plot
grid on;
88
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
89
Practical-18
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Analyse discrete time signals in frequency domain
Objectives: Write a program to compute N-point DFT of a given sequence. Plot itsmagnitude
and phase response.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
The DFT is one of the most powerful tools in digital signal processing which enables us to
findthe spectrum of a finite-duration signal.
The DFT is based on sampling the DTFT, at equally spaced frequency points. 𝑋�(𝑒�jω) is a
periodic function in ω with a period of 2π. If we take N samples in each period of 𝑋�(𝑒�jω) ,
the spacing between frequency points will be 2π. Hence, the frequency of the set of sinusoids
that we are looking for will be of the form 2π × 𝑘�., where we can select k=0,1,2…N-1.
Using N complex exponentials formula of DFT is given as below:
����������������������������������������������������������
𝑋(𝑘)�=� ∑ 𝑥(𝑛)𝑒−𝑁𝑗2𝜋𝑛𝑘
𝑁−1
𝑛�=�0
Suggested MATLAB function:
 freqs()
MATLAB Code:
90
Output:
clc;
clear all;
close all;
% Define the input sequence
x = [1, 2, 3, 4];
% Compute the N-point DFT
N = length(x); % Length of the sequence
X = fft(x, N);
% Compute the magnitude and phase responses
magnitude_X = abs(X);
phase_X = angle(X);
% Create frequency vector for plotting
fs = 1; % Sample rate (adjust as needed)
frequencies = (0:N-1) * fs / N;
% Plot the magnitude response
subplot(2, 1, 1);
stem(frequencies, magnitude_X, 'b', 'filled', 'LineWidth',2);
title('Magnitude Response (DFT)');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid on;
% Plot the phase response
subplot(2, 1, 2);
stem(frequencies, phase_X, 'g', 'filled', 'LineWidth',2);
title('Phase Response (DFT)');
xlabel('Frequency (Hz)');
ylabel('Phase (radians)');
grid on;
% Adjust the plot layout
sgtitle('DFT Analysis of Input Sequence');
91
Quiz:
1. Suppose we have two four point sequence x[n] and h[n] as follows:
 x[n] = cos(πn/2), n=0,1,2,3.
 h[n] = 2 n
n=0,1,2,3.
2. Calculate the four point DFT X[k].
3. Calculate the four point DFT H[k].
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
92
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
93
Practical-19
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Analyse discrete time signals in frequency domain
Objectives: Write a program to perform circular convolution of two sequences using DFT.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
Let us take two finite duration sequences x1(n) and x2(n), having integer length as N. Both the
discrete time domain signal is to be padded with zeros corresponding to the length of other
signal. Then take DFTs of the padded sequence and they are X1(K) and X2(k) respectively,
which is shown below
𝑋1(𝑘)�=� ∑ 𝑥1(𝑛)𝑒−�
𝑗2𝜋𝑛𝑘
𝑁
𝑁−1
𝑛=0
𝑋2(𝑘)�=� ∑ 𝑥2(𝑛)𝑒−�
𝑗2𝜋𝑛𝑘
𝑁
𝑁−1
𝑛=0
Now, we will try to find the DFT of another sequence x3(n), which is given as X3(K).
𝑋3 �=�𝑋1(𝑘)�∙�𝑋2(𝑘)
By taking the IDFT of the above we get
𝑋3(𝑘)�=
1
𝑁
�∑ 𝑥3(𝑛)𝑒−�
𝑗2𝜋𝑛𝑘
𝑁
𝑁−1
𝑘=0
Suggested MATLAB function:
Write a MATLAB code to create function of DFT and IDFT.
94
MATLAB Code:
clc;
clear all;
close all;
% Default input sequences
x = [1, 2, 3];
h = [0.5, 0.5];
% Compute the lengths of the sequences
N = length(x);
M = length(h);
L = max(N, M); % Length of the circular convolution result
% Zero-pad the sequences to make them equal in length
x = [x, zeros(1, L - N)];
h = [h, zeros(1, L - M)];
% Take the DFT of the sequences
X = fft(x);
H = fft(h);
% Multiply the DFTs element-wise
Y = X .* H;
% Take the inverse DFT to obtain the circular convolution result
y = ifft(Y);
% Plot the input sequences and the circular convolution result
n_x = 0:(N - 1);
n_h = 0:(M - 1);
n_y = 0:(L - 1);
subplot(3, 1, 1);
stem(n_x, x(1:N), 'filled', 'b', 'LineWidth',2);
title('Input Sequence x[n]');
xlabel('n');
ylabel('Amplitude');
grid on;
subplot(3, 1, 2);
stem(n_h, h(1:M),'filled', 'g', 'LineWidth',2);
title('Input Sequence h[n]');
xlabel('n');
ylabel('Amplitude');
grid on;
subplot(3, 1, 3);
stem(n_y, y, 'filled', 'r', 'LineWidth',2);
title('Circular Convolution Result y[n] = x[n] * h[n] (DFT)');
xlabel('n');
ylabel('Amplitude');
grid on;
% Adjust the plot layout
sgtitle('Circular Convolution Using DFT (Zero-Padding for Equal Length)');
95
Output:
Quiz:
1. What is circular convolution? How is it different from linear convolution?
x(n) = cos(πn/2) for n=0,1,2,3
h(n) = 2n
for n= 0,1,2
 Calculate y[n] = x[n] * h[n] by circular convolution
 Calculate y[n] of part (a) by multiplying the DFTs of x[n] and h[n] andperforming
an inverse DFT.
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
96
References used by the students:
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks
97
Practical-20
Date:
Competency and Practical Skills Introduction to the MATLAB technical computing
environment. Data analysis, modeling, visualization, and build computational competence with
MATLAB.
Relevant CO: Analyse discrete time signals in frequency domain
Objectives: Write a program to perform linear convolution of two sequences using DFT.
Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox
Theory:
Let us take two finite duration sequences x1(n) and x2(n), having integer length as N. Both the
discrete time domain signal is to be padded with zeros corresponding to the length of other
signal. Then take DFTs of the padded sequence and they are X1(K) and X2(k) respectively,
which is shown below
𝑋1(𝑘)�=� ∑ 𝑥1(𝑛)𝑒−�
𝑗2𝜋𝑛𝑘
𝑁
𝑁−1
𝑛=0
𝑋2(𝑘)�=� ∑ 𝑥2(𝑛)𝑒−�
𝑗2𝜋𝑛𝑘
𝑁
𝑁−1
𝑛=0
Now, we will try to find the DFT of another sequence x3(n), which is given as X3(K).
𝑋3 �=�𝑋1(𝑘)�∙�𝑋2(𝑘)
By taking the IDFT of the above we get
𝑋3(𝑘)�=
1
𝑁
�∑ 𝑥3(𝑛)𝑒−�
𝑗2𝜋𝑛𝑘
𝑁
𝑁−1
𝑘=0
Suggested MATLAB function:
Write a MATLAB code to create function of DFT and IDFT.
98
MATLAB Code:
clc;
clear all;
close all;
% Default input sequences
x = [1, 2, 3];
h = [0.5, 0.5];
% Compute the lengths of the sequences
N = length(x);
M = length(h);
L = N + M - 1;
% Zero-pad the sequences to make them equal in length (length(x) + length(h) -
1)
x = [x, zeros(1, M - 1)];
h = [h, zeros(1, N - 1)];
% Take the DFT of the sequences
X = fft(x, L);
H = fft(h, L);
% Multiply the DFTs element-wise
Y = X .* H;
% Take the inverse DFT to obtain the convolution result
y = ifft(Y);
% Plot the input sequences and the convolution result
n_x = 0:(N - 1);
n_h = 0:(M - 1);
n_y = 0:(L - 1);
subplot(3, 1, 1);
stem(n_x, x(1:N),'filled', 'g', 'LineWidth',2);
title('Input Sequence x[n]');
xlabel('n');
ylabel('Amplitude');
grid on;
subplot(3, 1, 2);
stem(n_h, h(1:M),'filled', 'b', 'LineWidth',2);
title('Input Sequence h[n]');
xlabel('n');
ylabel('Amplitude');
grid on;
subplot(3, 1, 3);
stem(n_y, y,'filled', 'r', 'LineWidth',2);
title('Convolution Result y[n] = x[n] * h[n] (DFT)');
xlabel('n');
ylabel('Amplitude');
grid on;
% Adjust the plot layout
sgtitle('Linear Convolution Using DFT (Zero-Padding for Equal Length)');
99
Output:
Quiz:
1. Find linear convolution of the sequences x(n) = {2,5,0,4}, n= 0:3 and x(n) = {4,1,3},
n=0:2 using (a) circular convolution and, (b) DFT and IDFT.
Suggested Reference:
 “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition,
Proakis, Manolakis, Pearson
 “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education
publication, 2nd Edition, 2003.
References used by the students:
100
Rubric wise marks obtained:
Faculty Sign:
Rubrics 1 2 3 4 5 Total
Marks

More Related Content

Similar to DSP_Lab_MAnual_-_Final_Edition[1].docx

ENG3104 Engineering Simulations and Computations Semester 2, 2.docx
ENG3104 Engineering Simulations and Computations Semester 2, 2.docxENG3104 Engineering Simulations and Computations Semester 2, 2.docx
ENG3104 Engineering Simulations and Computations Semester 2, 2.docxYASHU40
 
Signals And Systems Lab Manual, R18 Batch
Signals And Systems Lab Manual, R18 BatchSignals And Systems Lab Manual, R18 Batch
Signals And Systems Lab Manual, R18 BatchAmairullah Khan Lodhi
 
BS LAB Manual (1).pdf
BS LAB Manual  (1).pdfBS LAB Manual  (1).pdf
BS LAB Manual (1).pdfssuser476810
 
DESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGIC
DESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGICDESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGIC
DESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGICVLSICS Design
 
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)Omkar Rane
 
Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report Alamgir Hossain
 
Fundamentals of Digital Signal Processing - Question Bank
Fundamentals of Digital Signal Processing - Question BankFundamentals of Digital Signal Processing - Question Bank
Fundamentals of Digital Signal Processing - Question BankMathankumar S
 
Matlab 3
Matlab 3Matlab 3
Matlab 3asguna
 
Model-counting Approaches For Nonlinear Numerical Constraints
Model-counting Approaches For Nonlinear Numerical ConstraintsModel-counting Approaches For Nonlinear Numerical Constraints
Model-counting Approaches For Nonlinear Numerical ConstraintsQuoc-Sang Phan
 
Digital Signal Processing Tutorial:Chapt 1 signal and systems
Digital Signal Processing Tutorial:Chapt 1 signal and systemsDigital Signal Processing Tutorial:Chapt 1 signal and systems
Digital Signal Processing Tutorial:Chapt 1 signal and systemsChandrashekhar Padole
 
Basic simulation lab manual1
Basic simulation lab manual1Basic simulation lab manual1
Basic simulation lab manual1Janardhana Raju M
 
Be cps-18 cps13or23-module1
Be cps-18 cps13or23-module1Be cps-18 cps13or23-module1
Be cps-18 cps13or23-module1kavya R
 
Engineering C-programing module1 ppt (18CPS13/23)
Engineering C-programing module1 ppt (18CPS13/23)Engineering C-programing module1 ppt (18CPS13/23)
Engineering C-programing module1 ppt (18CPS13/23)kavya R
 

Similar to DSP_Lab_MAnual_-_Final_Edition[1].docx (20)

signal and system
signal and system signal and system
signal and system
 
DSP lab manual
DSP lab manualDSP lab manual
DSP lab manual
 
ENG3104 Engineering Simulations and Computations Semester 2, 2.docx
ENG3104 Engineering Simulations and Computations Semester 2, 2.docxENG3104 Engineering Simulations and Computations Semester 2, 2.docx
ENG3104 Engineering Simulations and Computations Semester 2, 2.docx
 
Mlab i
Mlab iMlab i
Mlab i
 
Signals And Systems Lab Manual, R18 Batch
Signals And Systems Lab Manual, R18 BatchSignals And Systems Lab Manual, R18 Batch
Signals And Systems Lab Manual, R18 Batch
 
BS LAB Manual (1).pdf
BS LAB Manual  (1).pdfBS LAB Manual  (1).pdf
BS LAB Manual (1).pdf
 
Dsp lab manual
Dsp lab manualDsp lab manual
Dsp lab manual
 
Python Manuel-R2021.pdf
Python Manuel-R2021.pdfPython Manuel-R2021.pdf
Python Manuel-R2021.pdf
 
Cse cpl manual-2016
Cse cpl manual-2016Cse cpl manual-2016
Cse cpl manual-2016
 
DESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGIC
DESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGICDESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGIC
DESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGIC
 
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)
 
Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report
 
Fundamentals of Digital Signal Processing - Question Bank
Fundamentals of Digital Signal Processing - Question BankFundamentals of Digital Signal Processing - Question Bank
Fundamentals of Digital Signal Processing - Question Bank
 
All projects
All projectsAll projects
All projects
 
Matlab 3
Matlab 3Matlab 3
Matlab 3
 
Model-counting Approaches For Nonlinear Numerical Constraints
Model-counting Approaches For Nonlinear Numerical ConstraintsModel-counting Approaches For Nonlinear Numerical Constraints
Model-counting Approaches For Nonlinear Numerical Constraints
 
Digital Signal Processing Tutorial:Chapt 1 signal and systems
Digital Signal Processing Tutorial:Chapt 1 signal and systemsDigital Signal Processing Tutorial:Chapt 1 signal and systems
Digital Signal Processing Tutorial:Chapt 1 signal and systems
 
Basic simulation lab manual1
Basic simulation lab manual1Basic simulation lab manual1
Basic simulation lab manual1
 
Be cps-18 cps13or23-module1
Be cps-18 cps13or23-module1Be cps-18 cps13or23-module1
Be cps-18 cps13or23-module1
 
Engineering C-programing module1 ppt (18CPS13/23)
Engineering C-programing module1 ppt (18CPS13/23)Engineering C-programing module1 ppt (18CPS13/23)
Engineering C-programing module1 ppt (18CPS13/23)
 

Recently uploaded

Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...Call girls in Ahmedabad High profile
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 

Recently uploaded (20)

Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 

DSP_Lab_MAnual_-_Final_Edition[1].docx

  • 1. 1 DIGITAL SIGNAL PROCESSING (3171003) LABORATORY MANUAL SEMESTER VII DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING GOVERNMENT ENGINEERING COLLEGE- MODASA
  • 2. 2 CERTIFICATE This is to certify that Mr. Doshi Parth Dipeshkumar Enrolment no 200160111007 of the seventh semester of B.E has satisfactorily completed his one full semester term work in “Digital Signal Processing (3171003)” satisfactorily in partial fulfilment of Bachelor of Electronics and Communication Engineering degree to be awarded by Gujarat Technological University. Prof. Ketu Patel Date: - …. /… /…….
  • 3. 3 Instructions for students: 1. The lab will meet every week. 2. Your activity, participation, and progress during the lab session will be part of your lab grade. 3. A lab report for each will be due the following week in lab. Your lab report should include relevant code fragments, figures, answers to questions in the quiz. 4. The lab consists of computer-based exercises. You are required to do programmingwith MATLAB. Follow the guidelines for the usage of online Matlab simulator. 5. MATLAB tutorial can be downloaded for free from the Mathworks website: http://www.mathworks.com/ 6. Other documentation can be obtained at: http://www.mathworks.com/access/helpdesk/help/helpdesk.shtml 7. Add your Matlab code and result in each experiment before taking printout.
  • 4. 4 Practical – Course Outcome Matrix Sr. No. Objective(s) of Experiment C O 1 C O 2 C O 3 C O 4 1. Generation of elementary sequences in discrete-time (i)unit impulse, (ii) unit step, (iii) unit ramp, (iv) exponential, (v)square, (vi) sin (vii) cosine,(viii) triangular,(ix) sinc signal √ 2. Write a MATLAB program to implement time shifting and time reversal operation on discrete time sequences. √ 3. Use help conv to find out how to use the conv command.Let f(n) = u(n) − u(n − 4) g(n) = n · u(n) − 2 (n − 4) · u(n − 4) + (n − 8) · u(n − 8). Make stem plots of the following convolutions. Use the MATLAB conv command to compute the convolutions. (a) f(n) ∗ f(n) (b) f(n) ∗ f(n) ∗ f(n) (c) f(n) ∗ g(n) (d) g(n) ∗ δ(n) (e) g(n) ∗ g(n) √ 4. Convolution of non-causal signals. f(n) = 3 δ(n + 2) − δ(n − 1) + 2 δ(n − 3) g(n) = u(n + 4) − u(n − 3) x(n) = f(n) ∗ g(n) √ 5. Suppose a system is implemented with the difference equation: y(n) = x(n) + 0.5 x(n − 1)+ 2 x(n-2) − 0.95 y(n − 1) Write your own MATLAB function, mysystem, to implement thisdifference equation using a for loop. (a) Is this system linear? Use your MATLAB function to confirm your answer: y1 = mysystem (x1)y2 = mysystem (x2) y3 = mysystem (2*x1+3*x2) Use any signals x1, x2 you like. (b) Is this system time-invariant? Confirm this in MATLAB (how?). (c) Compute and plot the impulse response of this system. √
  • 5. 5 Use x = [1, zeros(1,100)]; as input. (d) Define x(n) = cos(π n/8) [u(n) − u(n − 50)]. Compute the output of the system in two ways: (1) y(n) = h(n) ∗ x(n) using the conv command. (2) Use your function to find the output for this input signal. Are the two output signals you compute the same? 6. Write a MATLAB program to represent Moving average system and use it to compute the average of some sample values and to smooth a noisy sequence. √ 7. Write a MATLAB program to generate impulse response and step response of a system. √ 8. Write a program to perform linear convolution of two sequences. Get the input sequence and its duration form the user. Also plot all the sequences. √ 9. Write a program to find autocorrelation and cross correlation of sequences. Verify auto correlation property to find energy of the sequence and period of the sequence. √ 10. Write a program to compute DTFT of a sequence x[n]= (0.5)n u[n]. Plot its magnitude and phase response. √ 11. Write a program to demonstrate the time shifting and frequency shifting property of DTFT. √ 12. Write a program to find Z transform and its inverse Z transform of a sequence Write a program to plot pole-zero of a given FIR/IIR filter. √ 13. Write a program for Direct form – I,II form realization of the given IIR system function. √ 14. Write a program to design digital FIR filter using various windowing technique. √ 15. (A) Create Blackman Harris, Hamming and Gaussian window and plot them in the same filter design tool. (B) Design an FIR filter with side lobe attenuation of 40 dB using Kaiser Window of 200 points. √ 16. (A) Design low pass butter worth digital filter with given specification using impulse invariance method. (B) Design a high pass elliptical filter with given specification using impulse invariance method. (C) Design a band pass chebychev-2 filter with given specification using impulse in-variance method. √
  • 6. 6 17. Design a second-order digital bandpass Butterworth filter with the following specifications: fu= 2.6 kHz,fL = 2.4 kHz , fs = 8000 Hz. Plot the magnitude and phase response. √ 18. Write a program to compute N-point DFT of a given sequence. Plot its magnitude and phase response. √ 19. Write a program to perform circular convolution of two sequences using DFT. √ 20. Write a program to perform linear convolution of two sequences using DFT. √ Rubrics for Assessment: Index (Progressive Assessment Sheet) Sr. No. Objective(s) of Experiment Pag eNo. Date of perfo r mance Date of subm i ssion Asses sment Mark s Sign. of Teache r with date Remar ks 0. Mission & Vision 1. Generation of elementary sequences in discrete- time (i)unit impulse, (ii) unit step, (iii) unit ramp, (iv)exponential, (v)square, (vi) sin (vii) cosine,(viii) triangular,(ix) sinc signal 2. Write a MATLAB program to implement tim e shifting and time reversal operation on discrete Student Performance Evaluation Punctuality (2) Active Participation(2) Accuracy indata collection, analysis etc.(2) Submission of laboratory file and viva(2) Professional attitude, behaviour(2) Total Marks (10) Assessment: Full Satisfactory =2 Satisfactory = 1.5 Partially satisfactory =1 Not satisfactory =0
  • 7. 7 timesequences. 3. Use help conv to find out how to use the conv command. Let f(n) = u(n) − u(n − 4) g(n) = n · u(n) − 2 (n − 4) · u(n − 4) + (n − 8) · u(n − 8). Make stem plots of the following convolutions. Use the MATLAB conv command to compute theconvolutions. (a) f(n) ∗ f(n) (b) f(n) ∗ f(n) ∗ f(n) (c) f(n) ∗ g(n) (d) g(n) ∗ δ(n) (e) g(n) ∗ g(n) 4. Convolution of non-causal signals. f(n) = 3 δ(n + 2) − δ(n − 1) + 2 δ(n − 3) g(n) = u(n + 4) − u(n − 3) x(n) = f(n) ∗ g(n)
  • 8. 8 5. Suppose a system is implemented with thedifference equation: y(n) = x(n) + 0.5 x(n − 1)+ 2 x(n-2) − 0.95 y(n − 1) Write your own MATLAB function, mysystem, toimplement this difference equation using a for loop. (a) Is this system linear? Use your Matlabfunction to confirm your answer: y1 = mysystem (x1) y2 = mysystem (x2) y3 = mysystem (2*x1+3*x2) Use any signals x1, x2 you like. (b) Is this system time-invariant? Confirm this in MATLAB (how?). (c) Compute and plot the impulse response of this system. Use x = [1, zeros(1,100)]; as input. (d) Define x(n) = cos(π n/8) [u(n) − u(n − 50)]. 6. Write a MATLAB program to represent Moving average system and use it to compute the average of some sample values and to smooth a noisy sequence. 7. Write a MATLAB program to generate impulse response and step response of a system. 8. Write a program to perform linear convolution of two sequences. Get the input sequence and its duration form the user. Also plot all the sequences. 9. Write a program to find autocorrelation and cross correlation of sequences. Verify auto correlation property to find energy of the sequence and period of the sequence. 10. Write a program to compute DTFT of a sequence x[n]= (0.5)n u[n]. Plot its magnitude and phase response. 11. Write a program to demonstrate the time shifting and frequency shifting property of DTFT.
  • 9. 9 12. Write a program to find Z transform and its inverse Z transform of a sequence Write a program to plot pole-zero of a given FIR/IIR filter. 13. Write a program for Direct form – I,II form realization of the given IIR system function. 14. Write a program to design digital FIR filter using various windowing technique. 15. (A) Create Blackman Harris, Hamming and Gaussian window and plot them in the same filter design tool. (B) Design an FIR filter with side lobe attenuation of 40 dB using Kaiser Window of 200 points. 16. (A) Design low pass butter worth digital filter with given specification using impulse invariance method. (B) Design a high pass elliptical filter with given specification using impulse invariance method. (C)Design a band pass chebychev-2 filter with given specification using impulse in-variance method. 17. Design a second-order digital bandpass Butterworth filter with the following specifications: fu= 2.6 kHz, fL = 2.4 kHz , fs = 8000 Hz. Plot the magnitude and phase response. 18. Write a program to compute N-point DFT of a given sequence. Plot its magnitude and phase response. 19. Write a program to perform circular convolution of two sequences using DFT. 20. Write a program to perform linear convolution of two sequences using DFT. Total
  • 10. 10 Directorate of Technical Education (DTE) Vision  To facilitate quality technical and professional education having relevance for both industry and society, withmoral and ethical values, giving equal opportunity and access, aiming to prepare globally competent technocrats. Mission  Quality technical and professional education with continuous improvement of all the resources andpersonnel  To promote conducive ecosystem for Academic, Industry, Research, Innovations and Startups  To provide affordable quality professional education with moral values, equal opportunities, accessibilityand accountability  To allocate competent and dedicated human resources and infrastructure to the institutions for providingworld-class professional education to become a Global Leader (“Vishwa Guru”) Government Engineering College- Modasa Vision  To be a leading institution ensuring Academic Excellence, Research, Nurturing Innovation and EntrepreneurialAttitude to produce competent technocrats for service to Nation. Mission  To be a student centric institute imbibing experiential, innovative and lifelong learning skills, addressingsocietal problems.  To create a conducive ecosystem for Research, innovation & extension services.  To inculcate entrepreneurial attitude and values amongst Learners.  To Collaborate with Industries and other institutions to strengthen symbiotic relations.  To mentor aspiring Institutions to unleash their potential, towards nation building. Electronics and Communication Engineering Department Vision  To strive for academic excellence, enhance industry- institute interaction to create competent technocrats inrelevant areas for addressing ever changing needs of society.
  • 11. 11 Mission  To ensure dissemination of knowledge through effective teaching and learning process.  To strengthen collaboration with industries.  To prepare the students with multidisciplinary competence for their successful career and service to thesociety. PO (Program outcomes): Engineering Graduates will be able to 1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and an engineering specialization to the solution of complex engineering problems. 2. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences. 3. Design/development of solutions: Design solutions for complex engineering problems and design system components or processes that meet the specified needs with appropriate consideration for the public healthand safety and the cultural, societal, and environmental considerations. 4. Conduct investigations of complex problems: Use research-based knowledge and research methods including design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid conclusions. 5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineeringand IT tools including prediction and modeling to complex engineering activities with an understanding ofthe limitations. 6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice. 7. Environment and sustainability: Understand the impact of the professional engineering solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable development. 8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering practice. 9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams, and in multidisciplinary settings. 10. Communication: Communicate effectively on complex engineering activities with the engineering community and with society at large such as, being able to comprehend and write effective reports anddesign documentation, make effective presentations, and give and receive clear instructions. 11. Project management and finance: Demonstrate knowledge and understanding of the engineering and management principles and apply these to one’s own work, as a member and leader in a team, to manage projects and in multidisciplinary environments.
  • 12. 12 12. Life-long learning: Recognize the need for, and have the preparation and ability to engage inindependent and life-long learning in the broadest context of technological change. Program Specific Outcomes:  Employ domain knowledge of analog and digital electronics along with communication systems in the design and implementation of application-oriented engineering systems.  Develop programming skills in assembly, embedded C, and HDL to effectively address contemporaryand future challenges. Course Outcomes (COs):  Formulate engineering problems in terms of DSP tasks.  Analyze digital and analog signals and systems.  Analyze discrete time signals in frequency domain.  Design digital filters
  • 13. 13 Practical: 1 Date: Competency and Practical Skills: Introduction to the MATLAB technical computing environment which involves the basic concepts of the language such as data types, operators and control structures along with writing, executing and debugging Matlab code for various tasks such as data analysis, visualization and simulation. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Analyse digital and analog signals and systems Objectives: Generation of elementary sequences in discrete- time unit impulse, (ii) unit step, (iii) unit ramp, (iv) exponential, (v)square, (vi) sin (vii)cosine,(viii) triangular,(ix) sinc signal Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: Elementary signal plays a vital role in the study of signals and systems. It serves as a basic building blocks for the construction of most complex signals. These elementary signalsare also called standard signals. (i) Unit Impulse 𝛿�(𝑛�) = { 1 𝑛� = 0 0 𝑛� ≠ 0 (ii) Unit Step 𝑢�(𝑛�) = { 1 ≥ 0 0 𝑛� < 0 (iii) Unit ramp 𝑟�(𝑛�) = { 𝑛� 𝑛� ≥ 0 0 𝑛� < 0 (iv) Exponential 𝑥�(𝑛�) = 𝑎�n 𝑓�𝑜�𝑟� 𝑎�𝑙�𝑙� 𝑛� (v) Sinusoidal signal 𝑥�(𝑛�) = 𝐴� 𝑠�𝑖�𝑛�(𝑤�𝑛� + ∅) (vi) Cosine signal 𝑥�(𝑛�) = 𝐴� 𝑐�𝑜�𝑠�(𝑤�𝑛� + ∅) Write a script: In the main menu of Matlab, select file -> new -> M-file A new window will pop up. Type in your commands and then save the file with the .m extension under the default path matlab/work. Using the Matlab help system, click on Help -> MATLAB help or type helpdesk to open the help files. For a description of a single function or command, type help command_name on the command line, or use ’search’ in the help window. For example, type
  • 14. 14 help plot or help clc or help sinc Be aware that Matlab is case sensitive i.e. vectors ‘a’ and ‘A’ are different. Suggested MATLAB function: 1. exp() 2. sin() 3. cos() 4. square() 5. tripuls() 6. subplot() 7. stem() 8. title() 9. xlabel() 10. ylabel() 11. figure() MATLAB Code: clc; clear all; close all; figure('Name', 'Signal Plots - Figure 1', 'NumberTitle', 'off'); % Signal 1: Unit Impulse n = 0:4; a = zeros(size(n)); a(1) = 1; subplot(2, 1, 1); stem(n, a, 'filled', 'y', 'LineWidth', 1.5); grid on; title('Unit Impulse');xlabel('Samples');ylabel('Amplitude'); % Signal 2: Unit Step n = 0:4; a = ones(size(n)); subplot(2, 1, 2); stem(n, a, 'filled', 'b', 'LineWidth', 1.5); grid on; title('Unit Step');xlabel('Samples');ylabel('Amplitude'); figure('Name', 'Signal Plots - Figure 2', 'NumberTitle', 'off');
  • 15. 15 % Signal 3: Unit Ramp n = 0:4; a = n; subplot(2, 1, 1); stem(n, a, 'filled', 'r', 'LineWidth', 1.5); grid on; title('Unit Ramp');xlabel('Samples');ylabel('Amplitude'); % Signal 4: Exponential n = 0:0.5:2.5; a = exp(n); subplot(2, 1, 2); stem(n, a, 'g', 'LineWidth', 1.5); grid on; title('Exponential');xlabel('Samples');ylabel('Amplitude'); figure('Name', 'Signal Plots - Figure 3', 'NumberTitle', 'off'); % Signal 5: Random Signal a = rand(1, 5); subplot(2, 1, 1); stem(a, 'filled', 'm', 'LineWidth', 1.5); grid on; title('Random Signal');xlabel('Samples');ylabel('Amplitude'); % Signal 6: Square Wave n = 0:0.002:(1/30); a = square(2*pi*30*n); subplot(2, 1, 2); stem(n, a, 'filled', 'b', 'LineWidth', 1.5); grid on; title('Square Wave');xlabel('Time (s)');ylabel('Amplitude'); figure('Name', 'Signal Plots - Figure 4', 'NumberTitle', 'off'); % Signal 7: Sine Wave a = sin(2*pi*30*n); subplot(2, 1, 1); stem(n, a, 'filled', 'c', 'LineWidth', 1.5); grid on; title('Sine Wave');xlabel('Time (s)');ylabel('Amplitude'); % Signal 8: Cosine Wave a = cos(2*pi*30*n); subplot(2, 1, 2); stem(n, a, 'filled', 'k', 'LineWidth', 1.5); grid on; title('Cosine Wave');xlabel('Time (s)');ylabel('Amplitude'); figure('Name', 'Signal Plots - Figure 5', 'NumberTitle', 'off'); % Signal 9: Sinc Function n = linspace(-5, 5, 25); a = sinc(n); subplot(2, 1, 1); stem(n, a, 'filled','y', 'LineWidth', 1.5); grid on; title('Sinc Function');xlabel('Samples');ylabel('Amplitude');
  • 16. 16 Output: % Signal 10: Triangular Pulse n = -2:0.5:2; a = tripuls(n, 4); subplot(2, 1, 2); stem(n, a, 'filled', 'b', 'LineWidth', 1.5); grid on; title('Triangular Pulse');xlabel('Samples');ylabel('Amplitude');
  • 17. 17
  • 18. 18
  • 19. 19 Quiz: 1. A discrete-time signal is shown in the figure: Sketch and label each of the following signals  x[n-2]  x[4-n]  x[2n]  x[n]u[2-n]  x[n-1]δ[n-3] Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete-Time Signal Processing”: Oppenheim, Schafer, Buck Pearson education publication, 2nd Edition, 2003. References used by the students: Rubric-wise marks obtained: Rubrics 1 2 3 4 5 Total Marks Faculty Sign:
  • 20. 20 Practical: 2 Date: Competency and Practical Skills: Introduction to the MATLAB technical computing environment which involves the basic concepts of the language such as data types, operators and control structures along with writing, executing and debugging Matlab code for various tasks such as data analysis, visualization and simulation. Relevant CO: Analyse digital and analog signals and systems Objectives: Write a matlab program to implement time shifting and time reversal operation on discrete time sequences. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: Time shifting: Time shifting operation of a discrete-time signal x(n) can be represented by y(n) = x(n-k) The signal y(n) can be obtained by time shifting the signal x(n) by k units. If k is positive, it is delay and the shift is to the right, and if k is negative, it is advance and the shift is to the left. Time Reversal: The time reversal, also called the folding of a signal x(n) can be obtained by folding the signal about n = 0. This operation is very useful in convolution. It is denoted by x(-n). It is obtained by replacing the independent variable n by (–n).
  • 21. 21 Suggested MATLAB function: fliplr() iinput() MATLAB Code: clc; clear all; close all; n1 = input('Enter the amount to be delayed: '); n2 = input('Enter the amount to be advanced: '); n = -2:2; x = [-2, 3, 0, 1, 5]; % Original Signal subplot(3, 1, 1); stem(n, x, 'b', 'filled', 'LineWidth', 1.5); title('Signal x(n)');xlabel('n');ylabel('Amplitude'); % Delayed Signal x(n-n1) m = n + n1; y = x; subplot(3, 1, 2); stem(m, y, 'r', 'filled', 'LineWidth', 1.5); title(['Delayed Signal x(n-', num2str(n1), ')']); xlabel('n');ylabel('Amplitude'); % Advanced Signal x(n+n2) t = n - n2; z = x; subplot(3, 1, 3); stem(t, z, 'g', 'filled', 'LineWidth', 1.5); title(['Advanced Signal x(n+', num2str(n2), ')']); xlabel('n');ylabel('Amplitude'); figure; % Original Signal x(n) n = -1:2; x = [3, -1, 0, -4]; subplot(2, 1, 1); stem(n, x, 'b', 'filled', 'LineWidth', 1.5); axis([-3, 3, -5, 5]); title('Signal x(n)');xlabel('n');ylabel('Amplitude');
  • 22. 22 Output: % Reversed Signal x(-n) c = fliplr(x); y = -fliplr(n); subplot(2, 1, 2); stem(y, c, 'r', 'filled', 'LineWidth', 1.5); axis([-3, 3, -5, 5]); title('Reversed Signal x(-n)');xlabel('n');ylabel('Amplitude');
  • 23. 23 Quiz: 1. Sketch the following signals. (i) 𝑢�(−𝑡� + 2) (ii) 2 𝑟�(𝑡� − 2) (iii) 𝑢�(𝑡� + 3)𝑢�(−𝑡� + 3) Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer, Buck Pearsoneducation publication, 2nd Edition, 2003. References used by the students:
  • 24. 24 Rubric wise marks obtained: Rubrics 1 2 3 4 5 Total Marks Faculty Sign:
  • 25. 25 Practical: 3 Date: Competency and Practical Skills: Introduction to the MATLAB technical computing environment which involves the basic concepts of the language such as data types, operators and control structures along with writing, executing and debugging Matlab code for various tasks such as data analysis, visualization and simulation. Relevant CO: Analyse digital and analog signals and systems Objectives: Use help conv to find out how to use the conv command.Let f(n) = u(n) − u(n − 4) g(n) = n · u(n) − 2 (n − 4) · u(n − 4) + (n − 8) · u(n − 8). Make stem plots of the following convolutions. Use the MATLAB conv command to compute the convolutions. 1. f(n) ∗ f(n) 2. f(n) ∗ f(n) ∗ f(n) 3. f(n) ∗ g(n) 4. g(n) ∗ δ(n) 5. g(n) ∗ g(n Comment on your observations. What happens as you repeatedly convolve this signal with itself? Use the commands title, xlabel, ylabel to label the axes of your plots. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: Convolution: Convolution is a mathematical operation which is used to express the input- output relationship of an LTI system. It relates the input and impulse response of the system to output. The convolution of two signals x(n) and h(n) can be represented as: 𝑦�(𝑛�)�=�𝑥�(𝑛�)�∗�ℎ(𝑛�)�=�ℎ(𝑛�)�∗�𝑥�(𝑛�)
  • 26. 26 𝑦(𝑛)�=� ∑ 𝑥(𝑘)ℎ(𝑛 − 𝑘) ∞ 𝑘�=�0 �=� ∑ ℎ(𝑘𝑥(𝑛 − 𝑘) ∞ 𝑘�=�0 Suggested MATLAB function: 1. conv() 2. deconv() MATLAB Code: clc; clear all; close all; % Define the sequences f(n) and g(n) n = 0:15; f = (n >= 0) - (n >= 4); g = n.*(n >= 0) - 2*(n-4).*(n >= 4) + (n-8).*(n >= 8); % (a) Compute and plot f(n) * f(n) conv_ff = conv(f, f); subplot(3, 2, 1); stem(conv_ff, 'y', 'LineWidth', 1.5); title('f(n) * f(n)'); xlabel('n'); ylabel('Amplitude'); % (b) Compute and plot f(n) * f(n) * f(n) conv_fff = conv(conv_ff, f); subplot(3, 2, 2); stem(conv_fff, 'b', 'LineWidth', 1.5); title('f(n) * f(n) * f(n)'); xlabel('n'); ylabel('Amplitude'); % (c) Compute and plot f(n) * g(n) conv_fg = conv(f, g); subplot(3, 2, 3); stem(conv_fg, 'g', 'LineWidth', 1.5); title('f(n) * g(n)'); xlabel('n'); ylabel('Amplitude'); % (d) Compute and plot g(n) * δ(n) delta = [1, zeros(1, length(n)-1)]; % Delta function conv_g_delta = conv(g, delta); subplot(3, 2, 4); stem(conv_g_delta, 'r', 'LineWidth', 1.5); title('g(n) * δ(n)'); xlabel('n'); ylabel('Amplitude');
  • 27. 27 Output: Quiz: 1. Find output of the system with impulse response h(n) = {1, 2, 3,4}, n = -1:2 for an input x(n) = {1,1,1,1}, n=0:3. 2 . Perform linear convolution of following signals using graphical method. h(n) = u(n)-u(n-N) where N is an positive integer x(n)= an u(n) % (e) Compute and plot g(n) * g(n) conv_gg = conv(g, g); subplot(3, 2, 5); stem(conv_gg, 'c', 'LineWidth', 1.5); title('g(n) * g(n)'); xlabel('n'); ylabel('Amplitude');
  • 28. 28 Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students: Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 29. 29 Practical-4 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Analyse digital and analog signals and systems Objectives: Convolution of non-causal signals.  f(n) = 3 δ(n+2) – δ(n-1) + 2δ(n-3)  g(n) = u(n+4) – u(n-3)  x(n) = f(n) ∗ g(n) Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: Convolution: Convolution is a mathematical operation which is used to express the input- output relationship of an LTI system. It relates the input and impulse response of the system to output. The convolution of two signals x(n) and h(n) can be represented as: 𝑦�(𝑛�) = 𝑥�(𝑛�) ∗ ℎ(𝑛�) = ℎ(𝑛�) ∗ 𝑥�(𝑛�) ∞ ∞ 𝑦�(𝑛�) = Σ 𝑥�(𝑘�) ℎ(𝑛� − 𝑘�) = Σ ℎ(𝑘�)𝑥�(𝑛� − 𝑘�) k= –∞ k= –∞ Suggested MATLAB function:  conv()  deconv() Comment on your observations. Use the commands title, xlabel, ylabel to label the axes of your plots.
  • 30. 30 MATLAB Code: Output: clc; clear all; close all; % Define the discrete signals f(n) and g(n) n = -10:10; % Define a suitable range for n f = [0, 0, 3, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; % Values of f(n) extended to cover the appropriate range g = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; % Values of g(n) % Compute the convolution x(n) = f(n) * g(n) x = conv(f, g, 'same'); % 'same' option for keeping the output length the same as input % Plot the results subplot(3, 1, 1); stem(n, f, 'r', 'filled'); % Plot f(n) in red xlabel('n'); ylabel('f(n)'); title('Signal f(n)'); subplot(3, 1, 2); stem(n, g, 'b', 'filled'); % Plot g(n) in blue xlabel('n'); ylabel('g(n)'); title('Signal g(n)'); subplot(3, 1, 3); stem(n, x, 'g', 'filled'); % Plot x(n) in green xlabel('n'); ylabel('x(n)'); title('Convolution x(n) = f(n) * g(n)'); % Adjust the plot layout for better visualization sgtitle('Convolution of Non-Causal Signals'); % Display the plot grid on;
  • 31. 31 Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students: Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 32. 32 Practical-5 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Formulate engineering problems in terms of DSP tasks Objectives: Suppose a system is implemented with the difference equation: y(n) = x(n) + 0.5 x(n − 1)+ 2 x(n-2) − 0.95 y(n − 1) Write your own Matlab function, mysystem, to implement this difference equation using a for loop.If the input signal is N-samples long (0 ≤ n ≤ N − 1), your program should find the first N sample of the output y(n) (0 ≤ n ≤ N − 1). a) Is this system linear? Use your Matlab function to confirm your answer:  y1 = mysystem (x1)  y2 = mysystem (x2)  y3 = mysystem (2*x1+3*x2)  Use any signals x1, x2 you like. b) Is this system time-invariant?Confirm this in Matlab. c) Compute and plot the impulse response of this system.Use x = [1, zeros(1,100)]; as input. d) Define x(n) = cos(π n/8) [u(n) − u(n − 50)]. Compute the output of the system in two ways: (1) y(n) = h(n) ∗ x(n) using the conv command. (2) Use your function to find the output for this input signal. Are the two outputsignals you compute the same? Equipment/Instruments: MATLAB 2021a with Signal Processing Toolbox Theory: Linear System: Asystem which obeys the principle of superposition and homogeneity is called a linear system, and a system which does not obey the principle of superposition and homogeneity is called a non-linear system.
  • 33. 33 Homogeneity principle means system which produces an output y(n) for an input x(n) must produce an output ay(n) for an input ax(n). Superposition principle means a system which produces an output y1(n) for an input x1(n) and an output y2(n) for an input x2(n) must produce an output y1(n)+ y2(n) for an input x1(n) +x2(n). 𝑇�[𝑎�𝑥�1(𝑛�) + 𝑏�𝑥�2(𝑛�)] = 𝑎�𝑇�[𝑥�1(𝑛�)] + 𝑏�𝑇�[𝑥�2(𝑛�)] Time-invariant System: A system is said to be time-invariant (or shift-invariant) if its input/output characteristics does not change with time, i.e. a shift in the input results in a corresponding time shift in the output. Let x(n) be the input and let x(n-k) be the input delayed by k units. y(n) = T[x(n)] be the output for the input x(n). y(n,k) = T[x(n-k)] be the output for the delayed input. y(n-k) = y(n)|n=n-k be the output delayed by k units. Impulse Response of the System: Response of a system to an impulse input is called as impulse response of the system. It is denoted by h(n). h(n) = T [δ(n)] An LTI system is completely characterized by its impulse response. Suggested MATLAB function: a) function b) for c) input() d) impz() MATLAB Code: Objective A:
  • 34. 34 clc; clear all; close all; % Define the difference equation implementation N = 100; % Length of signals n = 0:N-1; x1 = rand(1, N); % Random signal 1 x2 = rand(1, N); % Random signal 2 x3 = 2 * x1 + 3 * x2; % Combined signal y1 = zeros(1, N); y2 = zeros(1, N); y3 = zeros(1, N); for k = 1:N if k == 1 y1(k) = x1(k); y2(k) = x2(k); y3(k) = 2 * x1(k) + 3 * x2(k); elseif k == 2 y1(k) = x1(k) + 0.5 * x1(k - 1); y2(k) = x2(k) + 0.5 * x2(k - 1); y3(k) = 2 * x1(k) + 3 * x2(k) + 0.5 * (2 * x1(k - 1) + 3 * x2(k - 1)); else y1(k) = x1(k) + 0.5 * x1(k - 1) + 2 * x1(k - 2) - 0.95 * y1(k - 1); y2(k) = x2(k) + 0.5 * x2(k - 1) + 2 * x2(k - 2) - 0.95 * y2(k - 1); y3(k) = 2 * x1(k) + 3 * x2(k) + 0.5 * (2 * x1(k - 1) + 3 * x2(k - 1)) + 2 * (2 * x1(k - 2) + 3 * x2(k - 2)) - 0.95 * (2 * y1(k - 1) + 3 * y2(k - 1)); end end % Check linearity if isequal(y3, y1 + 2 * y2) disp('The system is linear.'); else disp('The system is not linear.'); end % Plot the results subplot(3, 1, 1); stem(n, y1, 'b', 'LineWidth',2); title('y1 = mysystem(x1)'); xlabel('n'); ylabel('Amplitude'); subplot(3, 1, 2); stem(n, y2, 'g', 'LineWidth',2); title('y2 = mysystem(x2)'); xlabel('n'); ylabel('Amplitude'); subplot(3, 1, 3); stem(n, y3, 'r', 'LineWidth',2); title('y3 = mysystem(2*x1 + 3*x2)'); xlabel('n'); ylabel('Amplitude');
  • 35. 35 Output: Objective B: clc; clear all; close all; % Define the difference equation implementation N = 100; % Length of signals n = 0:N-1; x1 = rand(1, N); % Random signal 1 x2 = rand(1, N); % Random signal 2 y1 = zeros(1, N); y2 = zeros(1, N);
  • 36. 36 Output: % Define a time shift amount k = 5; % Shift amount % Shift the input signals x1_shifted = circshift(x1, [0, k]); x2_shifted = circshift(x2, [0, k]); % Recompute the outputs with the shifted inputs y1_shifted = zeros(1, N); y2_shifted = zeros(1, N); y3_shifted = zeros(1, N); for m = 1:N if m == 1 y1_shifted(m) = x1_shifted(m); y2_shifted(m) = x2_shifted(m); y3_shifted(m) = 2 * x1_shifted(m) + 3 * x2_shifted(m); elseif m == 2 y1_shifted(m) = x1_shifted(m) + 0.5 * x1_shifted(m - 1); y2_shifted(m) = x2_shifted(m) + 0.5 * x2_shifted(m - 1); y3_shifted(m) = 2 * x1_shifted(m) + 3 * x2_shifted(m) + 0.5 * (2 * x1_shifted(m - 1) + 3 * x2_shifted(m - 1)); else y1_shifted(m) = x1_shifted(m) + 0.5 * x1_shifted(m - 1) + 2 * x1_shifted(m - 2) - 0.95 * y1_shifted(m - 1); y2_shifted(m) = x2_shifted(m) + 0.5 * x2_shifted(m - 1) + 2 * x2_shifted(m - 2) - 0.95 * y2_shifted(m - 1); y3_shifted(m) = 2 * x1_shifted(m) + 3 * x2_shifted(m) + 0.5 * (2 * x1_shifted(m - 1) + 3 * x2_shifted(m - 1)) + 2 * (2 * x1_shifted(m - 2) + 3 * x2_shifted(m - 2)) - 0.95 * (2 * y1_shifted(m - 1) + 3 * y2_shifted(m - 1)); end end % Check if the system is time-invariant if isequal(y1_shifted, y1) && isequal(y2_shifted, y2) && isequal(y3_shifted, y3) disp('The system is time-invariant.'); else disp('The system is not time-invariant.'); end
  • 37. 37 Objective C: Output: clc; clear all; close all; % Define the impulse input x x_impulse = [1, zeros(1, 100)]; % Initialize the impulse response signal h_impulse = zeros(size(x_impulse)); % Compute the impulse response using the difference equation for k = 1:length(x_impulse) if k == 1 h_impulse(k) = x_impulse(k); elseif k == 2 h_impulse(k) = x_impulse(k) + 0.5 * x_impulse(k - 1); else h_impulse(k) = x_impulse(k) + 0.5 * x_impulse(k - 1) + 2 * x_impulse(k - 2) - 0.95 * h_impulse(k - 1); end end % Plot the impulse response stem(0:length(h_impulse) - 1, h_impulse, 'g', 'LineWidth',2); title('Impulse Response'); xlabel('n'); ylabel('Amplitude');
  • 38. 38 Objective D: Output: clc; clear all; close all; % Define the impulse input x x_impulse = [1, zeros(1, 100)]; % Initialize the impulse response signal h_impulse = zeros(size(x_impulse)); % Define x(n) = cos(π n/8) [u(n) − u(n − 50)] n = 0:150; % Adjust the length to accommodate the signal x_cosine = cos(pi * n / 8) .* (n >= 0 & n <= 50); % (1) Compute output using the conv command y_conv = conv(x_cosine, h_impulse, 'same'); % (2) Compute output using the implemented system y_mysystem = zeros(size(x_cosine)); for k = 1:length(x_cosine) if k == 1 y_mysystem(k) = x_cosine(k); elseif k == 2 y_mysystem(k) = x_cosine(k) + 0.5 * x_cosine(k - 1); else y_mysystem(k) = x_cosine(k) + 0.5 * x_cosine(k - 1) + 2 * x_cosine(k - 2) - 0.95 * y_mysystem(k - 1); end end % Compare the two output signals if isequal(y_conv, y_mysystem) disp('The two output signals are the same.'); else disp('The two output signals are not the same.'); end % Plot the output signals subplot(2, 1, 1); stem(n, y_conv); title('Output using conv'); subplot(2, 1, 2); stem(n, y_mysystem); title('Output using mysystem');
  • 39. 39 Quiz: I. For each of the following system determine whether the systems is 1) stable 2)causal 3) linear 4) time invariant 5) memoryless a. 𝑇�{𝑥�(𝑛�)} = 𝑔�(𝑛�). 𝑥�(𝑛�) 𝑤�𝑖�𝑡�ℎ 𝑔�𝑖�𝑣�𝑒�𝑛� 𝑔�(𝑛�) b. 𝑇�{𝑥�(𝑛�)} = ∑ 𝑥(𝑘) 𝑛 𝑘=𝑛0 c. 𝑇�{𝑥�(𝑛�)} = ∑ 𝑥(𝑘) 𝑘=𝑛+𝑛0 𝑘=𝑛−𝑛0 Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students:
  • 40. 40 Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 41. 41 Practical-6 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Formulate engineering problems in terms of DSP tasks Objectives: Write a matlab program to represent Moving average system and use it to compute the average of some sample values and to smooth a noisy sequence. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: Signal Smoothing or Averaging is the Fundamental Noise Reduction Tool in 1-D Signal Processing Such as a Monotonic Signal, Speech or Voice. Moving Average Filter is a Finite Impulse Response (FIR) Filter smoothing filter used for smoothing the signal from short term overshoots or noisy fluctuations and helps in retaining the true signal representation or retaining sharp step response. It is a simple yet elegant statistical tool for de-noising signals in the time domain. The general moving average system is defined by Suggested MATLAB function:  rand()  zeros()  ones()
  • 42. 42 MATLAB Code: Output: clc; clear all; close all; % Generate a sample noisy signal (you can replace this with your data) t = linspace(0, 1, 100); % Time vector noisy_signal = sin(2*pi*5*t) + 0.5*randn(1, 100); % Noisy sine wave % Define the window size (number of samples to average) window_size = 5; % Create a moving average filter kernel (rectangular window) ma_filter = ones(1, window_size) / window_size; % Apply the moving average filter to the noisy signal smoothed_signal = conv(noisy_signal, ma_filter, 'same'); % Compute the average of the noisy signal signal_average = mean(noisy_signal); % Plot the original noisy signal, smoothed signal, and the average subplot(3,1,1); plot(t, noisy_signal, 'b', 'LineWidth', 1.5); title('Noisy Signal'); xlabel('Time'); ylabel('Amplitude'); subplot(3,1,2); plot(t, smoothed_signal, 'b', 'LineWidth', 1.5); title('Smoothed Signal (Moving Average)'); xlabel('Time'); ylabel('Amplitude'); subplot(3,1,3); plot([0, 1], [signal_average, signal_average], 'r', 'LineWidth', 1.5); title('Signal Average'); xlabel('Time'); ylabel('Average Value'); % Display the average value fprintf('Signal Average: %.4fn', signal_average);
  • 43. 43 Quiz: 1. Find the impulse response of a Moving average system. 2. Check whether the moving average systems is 1) stable 2) causal 3) linear 4) time invariant 5) memoryless Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students:
  • 44. 44 Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 45. 45 Practical-7 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Analyse digital and analog signals and systems Objectives: Write a matlab program to generate impulse response and step response of a system. Equipment/Instruments: MATLAB 2021a with Signal Processing Toolbox Theory: Impulse Response: Response of a system to an impulse input is called as impulse response of the system. It is denoted by h(n). h(n) = T [δ(n)] An LTI system is completely characterized by its impulse response. We can check causality, stability of a system from its impulse response. Whether the system is FIR or IIR can also be checked from the length of its impulse response. Step Response: Output of the system for a unit step input is called as step response of the system. It is denoted by s(n). Unit step response can be obtained by convolving u(n) with the impulse response h(n) of the system. s(n) = T [u(n)] s(n) =u(n) * h(n) Suggested MATLAB function:  filter()  impz()  ones()  zeros()
  • 46. 46 MATLAB Code: Output: clc; clear all; close all; % Define the system's transfer function (example: 1/(s^2 + 2s + 2)) numerator = 1; denominator = [1, 2, 2]; % Compute the impulse response impulse_response = impz(numerator, denominator); % Generate the step response step_response = cumsum(impulse_response); % Time vector for plotting t = 0:length(impulse_response) - 1; % Plot the impulse response subplot(2, 1, 1); stem(t, impulse_response, 'r', 'LineWidth', 1.5); title('Impulse Response'); xlabel('Time'); ylabel('Amplitude'); % Plot the step response subplot(2, 1, 2); plot(t, step_response, 'b', 'LineWidth', 1.5); title('Step Response'); xlabel('Time'); ylabel('Amplitude');
  • 47. 47 Quiz: 1. Determine impulse response for each of the following system. a) Moving Average System b) Ideal Delay System c) Accumulator System d) Forward difference system e) Backward difference system f) Up-sampler system g) Down-sampler system Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students: Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 48. 48 Practical-8 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Formulate engineering problems in terms of DSP tasks Objectives: Write a program to compute convolution of two sequences. Get the input sequence and its duration from the user. Also plot all the sequences. Check the range of convolved signal. If first sequence has range from -2:2 and second sequence has range from 0:3, then convolved signal has range from -2:5. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Suggested Matlab functions:  input()  length()  error()  conv()  deconv() MATLAB Code: clc; clear all; close all; % Objective 1: Compute convolution of two sequences and plot them. % Get the input sequence and its duration from the user seq1 = input('Enter the first sequence: '); seq2 = input('Enter the second sequence: '); % Check if the lengths of the sequences are the same if length(seq1) ~= length(seq2) error('Input sequences must have the same length.'); end % Compute the convolution of the sequences convolved_seq = conv(seq1, seq2);
  • 49. 49 Output: % Plot the input sequences and the convolved sequence subplot(3, 1, 1); stem(1:length(seq1), seq1, 'b', 'filled', 'LineWidth', 2); title('First Sequence'); xlabel('Time'); ylabel('Amplitude'); subplot(3, 1, 2); stem(1:length(seq2), seq2, 'r', 'filled', 'LineWidth', 2); title('Second Sequence'); xlabel('Time'); ylabel('Amplitude'); subplot(3, 1, 3); stem(1:length(convolved_seq), convolved_seq, 'g', 'filled', 'LineWidth', 2); title('Convolved Sequence'); xlabel('Time'); ylabel('Amplitude'); % Objective 2: Check the range of the convolved signal range_convolved = min(convolved_seq):max(convolved_seq); fprintf('Range of convolved signal: %d:%dn', range_convolved(1), range_convolved(end));
  • 50. 50 Command Window Input and output : Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students: Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 51. 51 Practical-9 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Formulate engineering problems in terms of DSP tasks Objectives: Write a program to find autocorrelation and cross correlation of sequences. Verify auto correlation property to find energy of the sequence and period of the sequence. Equipment/Instruments: MATLAB 2021a with Signal Processing Toolbox Theory: Cross Correlation: The cross correlation between two different waveforms or signals is a measure of similarity or match or relatedness or coherence between one signal and the time delayed version of another signal. This means the cross correlation between two signals indicates how much one signal is related to the time delayed version of another signal. A measure of similarity between a pair of energy signals x(n) and y(n) is given by cross correlation. ∞ 𝑟�xy(𝑘�) = Σ 𝑥�(𝑛�)𝑦�(𝑛� − 𝑘�) 𝑘� = 0, ±1, ±2 … n= –∞ Autocorrelation: The autocorrelation gives the measure of match or similarity or relatedness or coherence between a signal and its time delayed version. This means that the autocorrelatin function is a special form of cross correlation function. ∞ 𝑟�xx(𝑘�) = Σ 𝑥�(𝑛�)𝑥�(𝑛� − 𝑘�) 𝑘� = 0, ±1, ±2 … n= –∞ The value of the autocorrelation function of a signal at origin (i.e. at k =0) is equal to the energy of the signal i.e. ∞ 𝑟�xx(0) = Σ 𝑥�(𝑛�)2 = 𝐸�x n= –∞
  • 52. 52 Suggested Matlab functions:  xcorr()  findpeaks()  diff()  mean() MATLAB Code: clc; clear all; close all; % Example input sequences x = [1, 2, 1, 2, 1]; y = [2, 1, 2, 1, 2]; % Compute the autocorrelation of sequence x autocorrelation_x = xcorr(x, x, 'biased'); % Compute the energy of sequence x using the autocorrelation property energy_x = sum(x.^2); % Find the period of sequence x using the autocorrelation property period_x = find(autocorrelation_x == max(autocorrelation_x)); % Compute the cross-correlation between sequences x and y crosscorrelation_xy = xcorr(x, y, 'biased'); % Compute the energy of sequence y using the autocorrelation property energy_y = sum(y.^2); % Find the period of sequence y using the autocorrelation property period_y = find(autocorrelation_x == max(autocorrelation_x)); % Display results fprintf('Autocorrelation of sequence x: n'); disp(autocorrelation_x); fprintf('Energy of sequence x: %.4fn', energy_x); fprintf('Period of sequence x: %dn', abs(period_x - length(x) + 1)); fprintf('Cross-correlation between sequences x and y: n'); disp(crosscorrelation_xy); fprintf('Energy of sequence y: %.4fn', energy_y); fprintf('Period of sequence y: %dn', abs(period_y - length(y)+1));
  • 53. 53 Output: Quiz: 1 . Find the autocorrelation of the signal x(n)= {1,2,4,6}, n = 0:3 2. Determine cross correlation of the signals x(n)= {1,2,3}, n = 0:2 and y(n) = {4,1, -2.5} n = 0:2 Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students: Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 54. 54 Practical-10 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Analyse discrete time signals in frequency domain Objectives: Write a program to compute DTFT of a sequence x(n)= 0.5n u(n). Plot its magnitude and phase response. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: Discrete-Time Fourier Transform The Fourier transform of a discrete-time sequence is known as the discrete-time Fourier transform (DTFT). Mathematically, the discrete-time Fourier transform (DTFT) of a discrete-timesequence x(n) is defined as − ∞ 𝑋�(𝜔�) = Σ 𝑥�(𝑛�)𝑒�–jωn n= –∞ Suggested MATLAB function:  angle()  abs()  plot() MATLAB Code: clc; clear all; close all;
  • 55. 55 Output: % Define the sequence x[n] n = 0:100; % Define a range of values for n x = (0.5).^n .* (n >= 0); % Define x[n] using the unit step function u[n] % Compute the DTFT N = length(n); % Length of the sequence w = linspace(0, 2*pi, N); % Angular frequencies from 0 to 2*pi X = fft(x, N); % Compute the FFT of x[n] % Plot the magnitude response subplot(2, 1, 1); plot(w, abs(X), 'b', 'LineWidth', 1.5); title('Magnitude Response (DTFT)'); xlabel('Frequency (radians/sample)'); ylabel('Magnitude'); grid on; % Plot the phase response subplot(2, 1, 2); plot(w, angle(X), 'g', 'LineWidth', 1.5); title('Phase Response (DTFT)'); xlabel('Frequency (radians/sample)'); ylabel('Phase (radians)'); grid on; % Adjust the plot layout sgtitle('DTFT Analysis of x[n] = (0.5)^n u[n]');
  • 56. 56 Quiz: 1. Find the frequency response H(ejw ) of the LTI system whose input and output satisfythe difference equation 𝑦(𝑛)��−�� 1 2 �𝑦(𝑛 − 1)�= �𝑥(𝑛)�− �2𝑥(𝑛 − 1)�+ �𝑥(𝑛 − 2) 2. Write a difference equation that characterizes a system when frequency responseis 𝐻(𝑒𝑗𝑤 )�=� 1� −� 1 2 𝑒𝑗𝑤 �+�𝑒−𝑗3𝑤 1� −� 1 2 𝑒𝑗𝑤 �+� 3 4 𝑒−𝑗2𝑤 3. Find  𝑋�(𝑒�j0)  𝑋�(𝑒�jπ) Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students: Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 57. 57 Practical-11 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Analyse discrete time signals in frequency domain Objectives: Write a program to demonstrate the time shifting and frequency shiftingproperty of DTFT. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: Discrete-Time Fourier Transform The Fourier transform of a discrete-time sequence is known as the discrete-time Fourier transform (DTFT). Mathematically, the discrete-time Fourier transform (DTFT) of a discrete-timesequence x(n) is defined as − ∞ 𝑿�(𝝎�) = Σ 𝒙�(𝒏�)𝒆�–𝒋�𝝎�𝒏� �����𝒏�= –∞ Time Shifting Property of Discrete-Time Fourier Transform Statement - The time-shifting property of discrete-time Fourier transform states that if a signal x(n) is shifted by k in time domain, then its DTFT is multiplied by 𝑒�–jωk. Therefore, if 𝒙�(𝒏�) ↔ 𝑿�(𝝎�) Then 𝑥�(𝑛� − 𝑘�) ↔ 𝑒�–jωk𝑋�(𝜔�) Where, k is an integer.
  • 58. 58 Suggested MATLAB function:  rand()  fftshift()  abs()  plot() MATLAB Code: clc; clear all; close all; % Define parameters N = 256; % Number of samples n = 0:N-1; % Time index fs = 1000; % Sampling frequency (Hz) t = n / fs; % Time vector (seconds) % Original signal x = cos(2*pi*100*t); % A cosine signal with a frequency of 100 Hz % Time-shifted signal delay_samples = 50; % Number of samples to delay by x_shifted = zeros(1, N); x_shifted(1+delay_samples:N) = x(1:N-delay_samples); % Frequency-shifted signal frequency_shift = 50; % Frequency shift in Hz x_freq_shifted = x .* exp(1j*2*pi*frequency_shift*t); % Compute the DTFT of each signal X = fft(x, N); X_shifted = fft(x_shifted, N); X_freq_shifted = fft(x_freq_shifted, N); % Frequency vector frequencies = (0:N-1) * fs / N; % Plot original signal subplot(3, 1, 1); plot(t, x, 'b', 'LineWidth', 1.5); title('Original Signal (100 Hz)'); xlabel('Time (s)'); ylabel('Amplitude'); grid on; % Plot time-shifted signal subplot(3, 1, 2); plot(t, x_shifted, 'r', 'LineWidth', 1.5); title('Time-Shifted Signal (50 Samples)'); xlabel('Time (s)'); ylabel('Amplitude'); grid on;
  • 59. 59 % Plot frequency-shifted signal subplot(3, 1, 3); plot(t, real(x_freq_shifted), 'g', 'LineWidth', 1.5); title('Frequency-Shifted Signal (50 Hz)'); xlabel('Time (s)'); ylabel('Amplitude'); grid on; % Plot the magnitude spectra of all signals figure; subplot(3, 1, 1); plot(frequencies, abs(X), 'b', 'LineWidth', 1.5); title('Magnitude Spectrum of Original Signal'); xlabel('Frequency (Hz)'); ylabel('Magnitude'); grid on; subplot(3, 1, 2); plot(frequencies, abs(X_shifted), 'r', 'LineWidth', 1.5); title('Magnitude Spectrum of Time-Shifted Signal'); xlabel('Frequency (Hz)'); ylabel('Magnitude'); grid on; subplot(3, 1, 3); plot(frequencies, abs(X_freq_shifted), 'g', 'LineWidth', 1.5); title('Magnitude Spectrum of Frequency-Shifted Signal'); xlabel('Frequency (Hz)'); ylabel('Magnitude'); grid on; sgtitle('Time and Frequency Shifting Properties of DTFT');
  • 61. 61 Quiz: 1. Prove following properties of DTFT.  Time shifting  Frequency Shifting 2. Find Fourier Transform of 𝑥�(𝑛�) = 𝑎�n𝑢�(𝑛� − 5) Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students: Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 62. 62 Practical-12 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Analyse discrete time signals in frequency domain Objectives: Write a program to find Z transform and its inverse Z transform of a sequence. Write a program to plot pole-zero of a given FIR/IIR filter. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: The Z-transform (ZT) is a mathematical tool which is used to convert the difference equations in time domain into the algebraic equations in z-domain. The Z-transform is a very useful tool in the analysis of a linear shift invariant (LSI) system. An LSI discrete time system is represented by difference equations. To solve these difference equations which are in time domain, they are converted first into algebraic equations in z- domain using the Z-transform, then the algebraic equations are manipulated in z-domain and the result obtained is converted back into time domain using the inverse Z-transform. Mathematically, if x(n) is a discrete-time signal or sequence, then its bilateral or two-sided Z- transform is defined as − ∞ 𝑋�(𝑍�) = Σ 𝑥�(𝑛�)𝑍�–n; 𝑍� = 𝑟� 𝑒�jω n= –∞ Region of Convergence (ROC) of Z-Transform The set of points in the z-plane, for which the Z-transform of a discrete-time sequence x(n), that is X(z) converges is called the region of convergence (ROC) of the Z-transform X(z). For any given discrete-time sequence, the Z-transform may or may not converge. If there is no point in the z-plane for which the function X(z) converges, then the sequence x(n) is said tobe having no z-transform.
  • 63. 63 Suggested MATLAB function:  ztrans()  iztrans ()  zplane() MATLAB Code: clc; clear all; close all; % Input sequence (replace this with your sequence) sequence = [1, 2, 3, 4, 5]; % Create a symbolic variable syms z; syms n; % Add a symbolic variable for the discrete-time index % Compute the Z-transform manually N = length(sequence); z_transform = 0; for n = 0:N-1 z_transform = z_transform + sequence(n+1) * z^(-n); end % Compute the inverse Z-transform manually inverse_z_transform = iztrans(z_transform, n); % Display the results disp('Original Sequence:'); disp(sequence); disp('Z-transform:'); disp(simplify(z_transform)); disp('Inverse Z-transform:'); disp(simplify(inverse_z_transform));
  • 64. 64 Output: Quiz: 1. Find the inverse z-transform of the following. 𝐻(𝑧)�=� 1�+�2𝑧−1�+𝑧−2� 1− 3 2 𝑧−1�+� 1 2 𝑧−1 for all possible ROCs 2. Find the z-transform of followings. 𝑥�(𝑛�) = 𝑛� 𝑎�n 𝑢�(𝑛�) where 𝑥�(𝑛�) = { 𝑎𝑛 o, otherwise 𝑎𝑛 �= �0 ≤ 𝑛 ≤ 𝑁 − 1 Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students:
  • 65. 65 Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 66. 66 Practical-13 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Analyse discrete time signals in frequency domain Objectives: Write a program for Direct form – I,II form realization of the given IIR system function. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: Direct-Form-I implementation of a 2nd-order digital filter. The DF-I structure has the following properties: 1. It can be regarded as a zero filter section followed in series by a pole filter section. 2. In most fixed-point arithmetic schemes (such as two's complement, the most commonly used) there is no possibility of internal filter overflow. That is, since there is fundamentally only one summation point in the filter, and since fixed-point overflow naturally “wraps around” from the largest positive to the largest negative number and vice versa, then as long as the final result y(n) is “in range”, overflow is avoided, even when there is overflow of intermediate results in the sum. This is an important, valuable, and unusual property of the DF-I filter structure
  • 67. 67 3. There are twice as many delays as are necessary. As a result, the DF-I structure is not canonical with respect to delay. In general, it is always possible to implement a Nth order filter using only N delay elements. 4. As is the case with all direct-form filter structures (those which have coefficients given by the transfer-function coefficients), the filter poles and zeros can be very sensitive to round-off errors in the filter coefficients. This is usually not a problem for a simple second-order section, but it can become a problem for higher order direct-form filters. This is the same numerical sensitivity that polynomial roots have with respect to polynomial-coefficient round-off. As is well known, the sensitivity tends to be larger when the roots are clustered closely together, as opposed to being well spread out in the complex plane. To minimize this sensitivity, it is common to factor filter transfer functions into series and/or parallel second-order sections. Direct-Form-II implementation of a 2nd-order digital filter. The DF-II structure has the following properties: 1. It can be regarded as a pole filter section followed by a zero filter section. 2. It is canonical with respect to delay. This happens because delay elements associated with the pole and zero sections are shared. 3. In fixed-point arithmetic, internal overflow can occur at the delay-line input (output of the leftmost summer in the figure, unlike in the DF-I implementation, which can only overflow if the output overflows. 4. As with all direct-form filter structures, the poles and zeros are sensitive to round-off errors in the coefficients, especially for high transfer-function orders. Lower sensitivity is obtained using series low-order sections (e.g., second order), or by using ladder or lattice filter structures.
  • 68. 68 MATLAB Code: Output: clc; clear all; close all; % Define the filter coefficients (replace with your own values) b = [1, 0.5, 0.25]; a = [1, -0.6, 0.1]; % Define the input signal (replace with your own signal) x = randn(1, 100); % Implement Direct Form I realization y_direct_form_I = filter(b, a, x); % Implement Direct Form II realization y_direct_form_II = filter(b, a, x); % Plot the input and output signals subplot(3, 1, 1); plot(x, 'b', 'LineWidth', 1.5); title('Input Signal'); subplot(3, 1, 2); plot(y_direct_form_I, 'g', 'LineWidth', 1.5); title('Direct Form I Output'); subplot(3, 1, 3); plot(y_direct_form_II, 'r', 'LineWidth', 1.5); title('Direct Form II Output');
  • 69. 69 Quiz: 1. Obtain the direct form II and parallel structures for the system 𝑦(𝑛)�=� 3 4 𝑦(𝑛 − 1)�−� 1 8 𝑦(𝑛 − 2)�+ �𝑥(𝑛)�+� 1 3 𝑥(𝑛 − 1) 2. Obtain the direct and cascade structure for the system function 𝐻�(𝑧�) = (1 + 0.25𝑧�–1 + 𝑧�–2)(1 + 0.5𝑧�–1 + 𝑧�–2) Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students: Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 70. 70 Practical-14 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Design digital filters Objectives: Write a program to design digital FIR filter using various windowing technique. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: An ideal low-pass filter has infinite attenuation in the stop-band. When we approximate an ideal filter with a practical filter using the window method, we accept some approximation error. The peak approximation error depends on the window type and is known for each window as reported in Table: Suggested MATLAB function:  fir1()  freqz ()  bartlett()  kaiser()
  • 71. 71 MATLAB Code: Output: clc; clear all; close all; % Define filter specifications fs = 1000; % Sampling frequency (Hz) N = 101; % Filter order (odd) fc = 100; % Cutoff frequency (Hz) % Design the filter using different windowing techniques % Rectangular Window rectangular_window = ones(1, N); rectangular_filter = fir1(N-1, fc/(fs/2), rectangular_window); % Hamming Window hamming_window = hamming(N); hamming_filter = fir1(N-1, fc/(fs/2), hamming_window); % Kaiser Window kaiser_window = kaiser(N, 5); % The third argument (beta) determines the shape of the window. kaiser_filter = fir1(N-1, fc/(fs/2), kaiser_window); % Frequency response plots freqz(rectangular_filter, 1, 1024, fs); title('Frequency Response (Rectangular Window)'); figure; freqz(hamming_filter, 1, 1024, fs); title('Frequency Response (Hamming Window)'); figure; freqz(kaiser_filter, 1, 1024, fs); title('Frequency Response (Kaiser Window)');
  • 72. 72
  • 73. 73 Quiz: 1. Design a low pass FIR filter with rectangular window with M=7. 𝐻𝑑(𝑤)�=�{ 𝑒−3𝑗𝑤 0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑤𝑒 |𝑤|�≤�𝑤𝑐 Wc is 1 rad/sec 2. Write a short note on designing of FIR filter using windowing method. Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003.
  • 74. 74 References used by the students: Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 75. 75 Practical-15 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Design digital filters Objectives: A) Create Blackman-Harris, Hamming and Gaussian window and plot them in the same filter design tool. (B) Design an FIR filter with side lobe attenuation of 40 dB using Kaiser Window of 200 points. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: Blackman window The Blackman window exhibits an even lower maximum stopband ripple (about 74 dB down) in the resulting FIR filter than the Hamming window. It is defined mathematically as 𝑤(𝑛)�= �0.42� − �0.5𝑐𝑜𝑠(2𝜋𝑛/𝑁 − 1)�+ �0.08𝑐𝑜𝑠( 4𝜋𝑛 𝑁 − 1) n = 0,1,2…….N-1 Hamming window The Hamming window coefficients are given by the following formula: 𝑤(𝑛)�= �0.54� − �0.46𝑐𝑜𝑠( 2𝜋𝑛 𝑁 − 1) n = 0,1,2……N-1 Gaussian window The coefficients of a Gaussian window are computed from the following equation: W(n) = 𝑒 −1�𝑛 2(𝑎(𝐿−1)/2 2 where –(L – 1)/2 ≤ n ≤ (L – 1)/2, and α is inversely proportional to the standard deviation, σ, of a Gaussian random variable. The exact correspondence with the standard deviation of a Gaussian probability density function is σ = (L – 1)/(2α).
  • 76. 76 Suggested MATLAB function:  blackman()  hamming()  zplane MATLAB Code: Objective A: clc; clear all; close all; % Define the length of the windows window_length = 200; % Create Blackman-Harris window blackman_harris_window = blackmanharris(window_length); % Create Hamming window hamming_window = hamming(window_length); % Create Gaussian window sigma = 0.4; % Adjust sigma as needed gaussian_window = gausswin(window_length, sigma); % Plot the windows figure; subplot(3, 1, 1); plot(blackman_harris_window); title('Blackman-Harris Window', 'b', 'LineWidth', 1.5); xlabel('Sample Index'); ylabel('Amplitude'); subplot(3, 1, 2); plot(hamming_window, 'r', 'LineWidth', 1.5); title('Hamming Window'); xlabel('Sample Index'); ylabel('Amplitude'); subplot(3, 1, 3); plot(gaussian_window, 'g', 'LineWidth', 1.5); title('Gaussian Window'); xlabel('Sample Index'); ylabel('Amplitude'); sgtitle('Window Functions');
  • 77. 77 Output: Objective B: clc; clear all; close all; % Filter specifications fs = 1000; % Sampling frequency (Hz) fpass = 100; % Passband frequency (Hz) fstop = 200; % Stopband frequency (Hz) delta_p = 0.01; % Passband ripple delta_s = 10^(-40/20); % Stopband attenuation (40 dB) % Calculate the required filter order using Kaiser formula A = -20*log10(min(delta_p, delta_s)); N = ceil((A - 8) / (2.285*(fstop - fpass) / fs)); % Design the FIR filter using Kaiser Window kaiser_window = kaiser(N+1, A); % Calculate the filter coefficients filter_coeffs = fir1(N, fstop/(fs/2), 'low', kaiser_window); % Plot the frequency response of the designed filter freqz(filter_coeffs, 1, 1024, fs);
  • 78. 78 Output: Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students: % Set the plot title and labels title('Frequency Response of Kaiser Window FIR Filter'); xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)');
  • 79. 79 Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 80. 80 Practical-16 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Design digital filters Objectives:  Design low pass butter worth digital filter with given specification usingimpulse invariance method.  Design a high pass elliptical filter with given specification using impulse invariance method.  Design a band pass chebychev-2 filter with given specification using impulse in- variancemethod. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory:
  • 81. 81 Suggested MATLAB function:  butter()  ellip()  cheby2() MATLAB Code: Objective A: Output: clc; clear all; close all; % Filter specifications fs = 1000; % Sampling frequency (Hz) fpass = 100; % Passband frequency (Hz) Ap = 1; % Passband ripple (dB) order = 6; % Filter order % Calculate the analog cutoff frequency analog_cutoff_freq = 2 * fs * tan(pi * fpass / fs); % Design the analog Butterworth filter [b, a] = butter(order, analog_cutoff_freq, 's'); % Convert the analog filter to a digital filter using impulse invariance [num, den] = impinvar(b, a, fs); % Plot the frequency response of the designed filter freqz(num, den, 1024, fs); title('Frequency Response of Low-Pass Butterworth Filter'); xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)');
  • 82. 82 Objective B: clc; clear all; close all; % Filter specifications fs = 1000; % Sampling frequency (Hz) fstop = 100; % Stopband frequency (Hz) As = 40; % Stopband attenuation (dB) Ap = 1; % Passband ripple (dB) % Calculate the analog cutoff frequency analog_cutoff_freq = 2 * pi * fstop / fs; % Design the elliptical digital filter with Wn as a one-element vector [N, Wn] = ellipord(analog_cutoff_freq/(2*pi), analog_cutoff_freq*1.2/(2*pi), Ap, As); [b, a] = ellip(N, Ap, As, Wn, 'high'); % Plot the frequency response of the designed high-pass elliptical filter freqz(b, a, 1024, fs); title('Frequency Response of High-Pass Elliptical Filter'); xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)');
  • 83. 83 Output: Objective C: clc; clear all; close all; % Filter specifications fs = 1000; % Sampling frequency (Hz) fpass1 = 80; % Lower passband frequency (Hz) fpass2 = 120; % Upper passband frequency (Hz) As = 40; % Stopband attenuation (dB) order = 10; % Filter order % Calculate the analog cutoff frequencies analog_cutoff_freq1 = 2 * fs * tan(pi * fpass1 / fs); analog_cutoff_freq2 = 2 * fs * tan(pi * fpass2 / fs); % Design the analog Chebyshev-II filter [b, a] = cheby2(order, As, [analog_cutoff_freq1, analog_cutoff_freq2], 's'); % Convert the analog filter to a digital filter using impulse invariance [num, den] = impinvar(b, a, fs); % Plot the frequency response of the designed filter freqz(num, den, 1024, fs); title('Frequency Response of Band-Pass Chebyshev-II Filter'); xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)');
  • 84. 84 Output: Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students:
  • 85. 85 Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 86. 86 Practical-17 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Design digital filters Objectives: Design a second-order digital bandpass Butterworth filter with the following specifications: fu= 2.6 kHz,fL = 2.4 kHz , fs = 8000 Hz. Plot the magnitude and phase response. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: Suggested MATLAB function:  butter()  freqs() MATLAB Code:
  • 87. 87 Output: clc; clear all; close all; % Filter specifications fs = 8000; % Sampling frequency (Hz) fu = 2600; % Upper band edge frequency (Hz) fL = 2400; % Lower band edge frequency (Hz) order = 2; % Filter order (second-order) % Normalize the frequencies fu_normalized = fu / (fs/2); fL_normalized = fL / (fs/2); % Design the digital Butterworth bandpass filter [b, a] = butter(order, [fL_normalized, fu_normalized], 'bandpass'); % Plot the frequency response of the designed filter freqz(b, a, 1024, fs); % Set plot titles and labels title('Magnitude and Phase Response of Butterworth Bandpass Filter'); xlabel('Frequency (Hz)'); ylabel('Magnitude (dB) / Phase (radians)'); % Show grid on the plot grid on;
  • 88. 88 Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students: Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 89. 89 Practical-18 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Analyse discrete time signals in frequency domain Objectives: Write a program to compute N-point DFT of a given sequence. Plot itsmagnitude and phase response. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: The DFT is one of the most powerful tools in digital signal processing which enables us to findthe spectrum of a finite-duration signal. The DFT is based on sampling the DTFT, at equally spaced frequency points. 𝑋�(𝑒�jω) is a periodic function in ω with a period of 2π. If we take N samples in each period of 𝑋�(𝑒�jω) , the spacing between frequency points will be 2π. Hence, the frequency of the set of sinusoids that we are looking for will be of the form 2π × 𝑘�., where we can select k=0,1,2…N-1. Using N complex exponentials formula of DFT is given as below: ���������������������������������������������������������� 𝑋(𝑘)�=� ∑ 𝑥(𝑛)𝑒−𝑁𝑗2𝜋𝑛𝑘 𝑁−1 𝑛�=�0 Suggested MATLAB function:  freqs() MATLAB Code:
  • 90. 90 Output: clc; clear all; close all; % Define the input sequence x = [1, 2, 3, 4]; % Compute the N-point DFT N = length(x); % Length of the sequence X = fft(x, N); % Compute the magnitude and phase responses magnitude_X = abs(X); phase_X = angle(X); % Create frequency vector for plotting fs = 1; % Sample rate (adjust as needed) frequencies = (0:N-1) * fs / N; % Plot the magnitude response subplot(2, 1, 1); stem(frequencies, magnitude_X, 'b', 'filled', 'LineWidth',2); title('Magnitude Response (DFT)'); xlabel('Frequency (Hz)'); ylabel('Magnitude'); grid on; % Plot the phase response subplot(2, 1, 2); stem(frequencies, phase_X, 'g', 'filled', 'LineWidth',2); title('Phase Response (DFT)'); xlabel('Frequency (Hz)'); ylabel('Phase (radians)'); grid on; % Adjust the plot layout sgtitle('DFT Analysis of Input Sequence');
  • 91. 91 Quiz: 1. Suppose we have two four point sequence x[n] and h[n] as follows:  x[n] = cos(πn/2), n=0,1,2,3.  h[n] = 2 n n=0,1,2,3. 2. Calculate the four point DFT X[k]. 3. Calculate the four point DFT H[k]. Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students:
  • 92. 92 Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 93. 93 Practical-19 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Analyse discrete time signals in frequency domain Objectives: Write a program to perform circular convolution of two sequences using DFT. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: Let us take two finite duration sequences x1(n) and x2(n), having integer length as N. Both the discrete time domain signal is to be padded with zeros corresponding to the length of other signal. Then take DFTs of the padded sequence and they are X1(K) and X2(k) respectively, which is shown below 𝑋1(𝑘)�=� ∑ 𝑥1(𝑛)𝑒−� 𝑗2𝜋𝑛𝑘 𝑁 𝑁−1 𝑛=0 𝑋2(𝑘)�=� ∑ 𝑥2(𝑛)𝑒−� 𝑗2𝜋𝑛𝑘 𝑁 𝑁−1 𝑛=0 Now, we will try to find the DFT of another sequence x3(n), which is given as X3(K). 𝑋3 �=�𝑋1(𝑘)�∙�𝑋2(𝑘) By taking the IDFT of the above we get 𝑋3(𝑘)�= 1 𝑁 �∑ 𝑥3(𝑛)𝑒−� 𝑗2𝜋𝑛𝑘 𝑁 𝑁−1 𝑘=0 Suggested MATLAB function: Write a MATLAB code to create function of DFT and IDFT.
  • 94. 94 MATLAB Code: clc; clear all; close all; % Default input sequences x = [1, 2, 3]; h = [0.5, 0.5]; % Compute the lengths of the sequences N = length(x); M = length(h); L = max(N, M); % Length of the circular convolution result % Zero-pad the sequences to make them equal in length x = [x, zeros(1, L - N)]; h = [h, zeros(1, L - M)]; % Take the DFT of the sequences X = fft(x); H = fft(h); % Multiply the DFTs element-wise Y = X .* H; % Take the inverse DFT to obtain the circular convolution result y = ifft(Y); % Plot the input sequences and the circular convolution result n_x = 0:(N - 1); n_h = 0:(M - 1); n_y = 0:(L - 1); subplot(3, 1, 1); stem(n_x, x(1:N), 'filled', 'b', 'LineWidth',2); title('Input Sequence x[n]'); xlabel('n'); ylabel('Amplitude'); grid on; subplot(3, 1, 2); stem(n_h, h(1:M),'filled', 'g', 'LineWidth',2); title('Input Sequence h[n]'); xlabel('n'); ylabel('Amplitude'); grid on; subplot(3, 1, 3); stem(n_y, y, 'filled', 'r', 'LineWidth',2); title('Circular Convolution Result y[n] = x[n] * h[n] (DFT)'); xlabel('n'); ylabel('Amplitude'); grid on; % Adjust the plot layout sgtitle('Circular Convolution Using DFT (Zero-Padding for Equal Length)');
  • 95. 95 Output: Quiz: 1. What is circular convolution? How is it different from linear convolution? x(n) = cos(πn/2) for n=0,1,2,3 h(n) = 2n for n= 0,1,2  Calculate y[n] = x[n] * h[n] by circular convolution  Calculate y[n] of part (a) by multiplying the DFTs of x[n] and h[n] andperforming an inverse DFT. Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003.
  • 96. 96 References used by the students: Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks
  • 97. 97 Practical-20 Date: Competency and Practical Skills Introduction to the MATLAB technical computing environment. Data analysis, modeling, visualization, and build computational competence with MATLAB. Relevant CO: Analyse discrete time signals in frequency domain Objectives: Write a program to perform linear convolution of two sequences using DFT. Equipment/Instruments: MATLAB 2023a with Signal Processing Toolbox Theory: Let us take two finite duration sequences x1(n) and x2(n), having integer length as N. Both the discrete time domain signal is to be padded with zeros corresponding to the length of other signal. Then take DFTs of the padded sequence and they are X1(K) and X2(k) respectively, which is shown below 𝑋1(𝑘)�=� ∑ 𝑥1(𝑛)𝑒−� 𝑗2𝜋𝑛𝑘 𝑁 𝑁−1 𝑛=0 𝑋2(𝑘)�=� ∑ 𝑥2(𝑛)𝑒−� 𝑗2𝜋𝑛𝑘 𝑁 𝑁−1 𝑛=0 Now, we will try to find the DFT of another sequence x3(n), which is given as X3(K). 𝑋3 �=�𝑋1(𝑘)�∙�𝑋2(𝑘) By taking the IDFT of the above we get 𝑋3(𝑘)�= 1 𝑁 �∑ 𝑥3(𝑛)𝑒−� 𝑗2𝜋𝑛𝑘 𝑁 𝑁−1 𝑘=0 Suggested MATLAB function: Write a MATLAB code to create function of DFT and IDFT.
  • 98. 98 MATLAB Code: clc; clear all; close all; % Default input sequences x = [1, 2, 3]; h = [0.5, 0.5]; % Compute the lengths of the sequences N = length(x); M = length(h); L = N + M - 1; % Zero-pad the sequences to make them equal in length (length(x) + length(h) - 1) x = [x, zeros(1, M - 1)]; h = [h, zeros(1, N - 1)]; % Take the DFT of the sequences X = fft(x, L); H = fft(h, L); % Multiply the DFTs element-wise Y = X .* H; % Take the inverse DFT to obtain the convolution result y = ifft(Y); % Plot the input sequences and the convolution result n_x = 0:(N - 1); n_h = 0:(M - 1); n_y = 0:(L - 1); subplot(3, 1, 1); stem(n_x, x(1:N),'filled', 'g', 'LineWidth',2); title('Input Sequence x[n]'); xlabel('n'); ylabel('Amplitude'); grid on; subplot(3, 1, 2); stem(n_h, h(1:M),'filled', 'b', 'LineWidth',2); title('Input Sequence h[n]'); xlabel('n'); ylabel('Amplitude'); grid on; subplot(3, 1, 3); stem(n_y, y,'filled', 'r', 'LineWidth',2); title('Convolution Result y[n] = x[n] * h[n] (DFT)'); xlabel('n'); ylabel('Amplitude'); grid on; % Adjust the plot layout sgtitle('Linear Convolution Using DFT (Zero-Padding for Equal Length)');
  • 99. 99 Output: Quiz: 1. Find linear convolution of the sequences x(n) = {2,5,0,4}, n= 0:3 and x(n) = {4,1,3}, n=0:2 using (a) circular convolution and, (b) DFT and IDFT. Suggested Reference:  “Digital Signal Processing: Principles, Algorithm & Application”, 4thedition, Proakis, Manolakis, Pearson  “Discrete Time Signal Processing”:Oppeheim, Schafer,Buck Pearson education publication, 2nd Edition, 2003. References used by the students:
  • 100. 100 Rubric wise marks obtained: Faculty Sign: Rubrics 1 2 3 4 5 Total Marks