0% found this document useful (0 votes)
25 views137 pages

EE-21026 Muhammad Uzair

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

EE-21026 Muhammad Uzair

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

NED University of Engineering & Technology

Department of Electrical Engineering

LAB MANUAL
For the course

Digital Signal Processing


(EE-395) For T.E.(EE)
(EE-493) For T.E.(BM)

Instructor name:_________________________________
Mr. Muhammad Omar

Student name:____________________________________
Muhammad Uzair Rashid

Roll no: 026 Batch:___________________


2021

Semester: Fall Year:________________


2023-24
LAB MANUAL
For the course

Digital Signal Processing


(EE-395) For T.E.(EE)
(EE-493) For T.E.(BM)

Content Revision Team:


Mr. Muhammad Omar & Mr. Nabeel Fayyaz
Last Revision Date: 02-03-2023

Approved By

The Board of Studies of Department of Electrical Engineering

____________________ ____________________

____________________ ___________________

____________________ ____________________
To be filled by lab technician

Attendance: Present out of _____ Lab sessions

Attendance Percentage ________

To be filled by Lab Instructor

Lab Score Sheet

Roll No. Rubric Rubric Rubric Rubric Rubric Rubric OEL/PBL Final LAB Attendance Final weighted Score for
based based based based based based Rubric Rubric Percentage MIS System
Lab I Lab II Lab III Lab IV Lab V Lab VI Score Score [10(A)+10(B)+5(C)]/25
A B C Round to next higher
multiple of 5

EE-395 / EE-493 Rubric Based Labs 1, 2, 3, 6, 9, 10

Note: All Rubric Scores must be in the next higher multiple of 5 for correct entry in MIS system.
CONTENTS

S.No. Date Title of Experiment Signature

25-10-23 To study the effects of Sampling in Discrete Time


1 Signals.

08-11-23 To study the effects of Quantization in Discrete Time


2 Discrete Valued Signals.

22-11-23 To study and verify Discrete-Time convolution and its


3 properties.

29-11-23 To study Discrete-Time correlation.


4
13-12-23 The Discrete Fourier Transform as a Linear
5 Transformation

27-12-23 Studying Discrete Fourier Transform using an audio


6 signal example

03-01-24
7 Relationship between Laplace and CTFT.

08-01-24 Relationship between Z transform and DTFT.


8

9 10-01-24 Designing FIR filters with windowing

10-01-24 Designing IIR filters using FDA tool


10
Open Ended Lab Part 1
11
(due after lab 2)
Open Ended Lab Part 2
12
(due after lab 6)
LAB SESSION 01
OBJECTIVE:

To study the relationship between discrete-time and continuous time signals by examining
sampling and aliasing.

THEORY:

Signals are physical quantities that carry information in their patterns of variation. Continuous-
time signals are continuous functions of time, while discrete-time signals are sequences of
numbers. If the values of a sequence are chosen from a finite set of numbers, the sequence is known
as a digital signal. Continuous-time, continuous-amplitude signals are also known as analog
signals.

Analog phenomenon is continuous – like a human speech of speaker, or a continuously rotating


disc attached to the shaft of motor etc. With analog phenomena, there is no clear separation
between one point and the next; in fact, between any two points, an infinite number of other points
exist. Discrete phenomenon, on the other hand, is clearly separated. There's a point (in time or
space), and then there's a neighboring point, and there's nothing between the two.

Signal processing is concerned with the acquisition, representation, manipulation, transformation,


and extraction of information from signals. In analog signal processing these operations are
implemented using analog electronic circuits. Converting the continuous phenomena of images,
sound, and motion into a discrete representation that can be handled by a computer is called analog-
to-digital conversion. Digital signal processing involves the conversion of analog signals into
digital, processing the obtained sequence of finite precision numbers using a digital signal
processor or general purpose computer, and, if necessary, converting the resulting sequence back
into analog form. When stored in a digital computer, the numbers are held in memory locations,
so they would be indexed by memory address. Regardless of the medium (either sound or an
image), analog-to-digital conversion requires the same two steps: Sampling and Quantization.
Sampling: This operation chooses discrete (finite) points at which to measure a continuous
phenomenon (which we will also call a signal). In the case of sound, the sample points are evenly
separated in time. In the case of images, the sample points are evenly separated in space.
Sampling Rate: The number of samples taken per unit time or unit space is called the sampling
rate. The frequency of sampled/discrete phenomenon (signal) can be calculated as
fd = F /Fs (cycles/sec )/(samples/sec) = cycles/ samples
Where, F = Frequency of analog or continuous phenomenon (signal). [Unit: cycles/sec]
Fs = Sampling frequency or sampling rate [Unit: samples/sec]
fd = Frequency of Discrete phenomenon (signal). [Unit: cycles/sample]
Sampling Theorem: A continuous time phenomenon or signal like x(t) can be reconstructed
exactly from its samples x(n) = x(nTs), if the samples are taken at a rate Fs = 1/Ts
that is greater than twice the frequency of the signal being sampled i.e. Fs ≥ 2 ∗ F.

Mathematically,

Aliasing: A common problem that arises when sampling a continuous signal is aliasing, where a
sampled signal has replications of its sinusoidal components which can interfere with other
components. It is an effect that causes two discrete time signals to become indistinct due to
improper sampling (fd>1/2 cycles/sample).

PROCEDURE:

1. Simulate and plot two CT signals of 10 Hz and 110 Hz for 0 < t < 0.2 secs.
2. Sample at Fs = 100 Hz and plot them in discrete form.
3. Observe and note the aliasing effects.
4. Explore and learn.
STEPS:
1. Make a folder at desktop and name it as your current directory within MATLAB.
2. Open M-file editor and type the following code:

clear all;close all;clc;

F1 = 10;
F2 = 110;
Fs = 100;
Ts = 1/Fs;
t = [0 : 0.0005 : 0.2];
x1t = cos(2*pi*F1*t);
x2t = cos(2*pi*F2*t);
figure,
plot(t,x1t,t,x2t, 'LineWidth',2);
xlabel('cont time (sec)');
ylabel('Amp');
xlim([0 0.1]);
grid on;
legend('10Hz','110Hz');
title('Two CTCV sinusoids plotted');

3. Save the file as P011.m in your current directory and ‘run’ it, either using F5 key or writing
the file name at the command window.
(Check for the correctness of the time periods of both sinusoids.)

Now add the following bit of code at the bottom of your P011.m file and save.

nTs = [0 :Ts : 0.2];


n = [1 : length(nTs)-1 ];

x1n = cos(2*pi*F1*nTs);
x2n = cos(2*pi*F2*nTs);

figure,
subplot(2,1,1),
stem(nTs,x1n,'LineWidth',2);
grid on;
xlabel('discrete time (sec)');
ylabel('Amp');
xlim([0 0.1]);

subplot(2,1,2)
stem(nTs,x2n,'LineWidth',2);
grid on;
title('110Hz sampled')
xlabel('discrete time(sec)');
ylabel('Amp');
xlim([0 0.1]);

1. Before hitting the ‘run’, just try to understand what the code is doing and try to link it with
what we have studied in classes regarding concepts of frequency for DT signals.
2. Now ‘run’ the file and observe both plots.
To see what is really happening, type the following code at the bottom of your existing P011.m
file and run again.

figure,
plot(t,x1t,t,x2t);
hold;
stem(nTs,x1n,'r','LineWidth',2);

xlabel('time (sec)');
ylabel('Amp');
xlim([0 0.05]);

legend('10Hz','110Hz');

3. Observe the plots.

RESULT:

Explain (write) in your own words the cause and effects of what you just saw.
LAB TASKS:

1. Consider the following CT signal:


x(t) = sin (2 pi F0 t). The sampled version will be:
x(n) = sin (2 pi F0/Fs n),
where n is a set of integers and sampling interval Ts=1/Fs.
Plot the signal x(n) for n = 0 to 99
for Fs = 5 kHz and F1 = 0.5, 2, 3 and 4.5 kHz. Explain the similarities and differences among
various plots.

2. Generate a tone in MATLAB with varying frequency f = 1000,2000,3000,4000, 5000, 6000,


8000, 9000, 25000,-1000,-2000,-3000 Hz with Fs = 8000 samples/sec.
Listen to the tones,and observe at Sounds like what frequency?
Also Specify whether Aliasing is happening or not.

3. Record a sentence in your voice.(you may use Simulink /audacity to record).Change Fs


=44100, 22050, 11025, 8192, 4096 , 2048 , 1024
and observe

a) Voice quality during playback [Excellent/Good/OK/Bad]


b) File size in kilobytes
c) Aliasing happening or not?
Lab session 1
1. Consider the following CT signal:
x(t) = sin (2 pi F0 t). The sampled version will be:
x(n) = sin (2 pi F0/Fs n),
where n is a set of integers and sampling interval Ts=1/Fs.
Plot the signal x(n) for n = 0 to 99
for Fs = 5 kHz and F1 = 0.5, 2, 3 and 4.5 kHz. Explain the similarities and differences
among various plots.

Matlab Code:
close all, clear all, clc;
Fs = 5000, Ts = 1/Fs;
f = [500,2000,3000,4500] %initializing an array to observe output at
different frequencies
figure,
for i = 1:length(f) %initializing for loop for multiple CTCV plots
F = f(i);
t = [0:0.000005:0.2];
xt = sin(2*pi*F*t);
hold on
subplot(2,2,i);
plot(t,xt,'LineWidth',2)
xlabel('Time(sec)'), ylabel('Amp'), xlim([0 0.005]), grid on;
title('CTCV Sinusoid');
end
hold off
figure,
for i = 1:length(f) %initializng another for loop for DTDV plots
F = f(i);
nTs = [0:Ts:0.02]; %sampling of CTCV signal
n = [1:length(nTs-1)]; %array for DTDV
xn = sin(2*pi*F*nTs);
hold on
subplot (2,2,i);
stem (nTs, xn, 'LineWidth',2); %function for DT plot
title ('DTDV'), xlim([0 0.005]);
grid on, xlabel('Discrete time (samples/cycle)'), ylabel('Amp');
end
hold off
Similarities:
Plot 1 looks exactly similar to the plot 4 while plot 2 looks similar to the plot 3 in the discrete time.

Dissimilarities:
If we observe the plots in continuous time, Plot 1 and plot 4 are distinct while plot 2 and plot 3 are also
distinct which is contrary to what observed in discrete time.

Comments: It can be said that the frequencies of 3000Hz and 4500Hz are under-sampled since Fs =
5000Hz and does not match the Nyquist’s criteria i.e. Fs>=2F. Therefore, Plot 4 and plot 3 looks like an
aliased version of plot 1 and plot 2 respectively.
2. Generate a tone in MATLAB with varying frequency f = 1000,2000,3000,4000, 5000,
6000, 8000, 9000, 25000,-1000,-2000,-3000 Hz with Fs = 8000 samples/sec. Listen to
the tones, and observe at Sounds like what frequency? Also Specify whether Aliasing is
happening or not.

Matlab Code:
clear all, close all, clc;
F = -3000; %Differrent frequencies are placed here to observe different
sampled sounds
Fs = 8000, Ts = 1/Fs;
nTs = [0:Ts:1];
x = cos(2*pi*F*nTs);
sound(x);

Comments:
Unique sounds were observed at frequencies ranging from 1kHz - 4kHz. The negative
frequencies also produced the same sound as positive frequencies verifying the Nyquist’s
criteria of –Fs/2. 7kHz, 9kHz and 25kHz were an aliased version of 1kHz while 6kHz of 2kHz and
5kHz of 3kHz. 8kHz did not produce a sound at all because it is an alias of 0Hz which represents
a DC value.
3. Record a sentence in your voice.(you may use Simulink /audacity to record).Change Fs
=44100, 22050, 11025, 8192, 4096 , 2048 , 1024 and observe
a) Voice quality during playback [Excellent/Good/OK/Bad]
b) File size in kilobytes
c) Aliasing happening or not?
Using DSP system tool box in Simulink observing my voice at different sampling rates

Sampling Voice Quality File Size Aliasing?


Frequency (Hz) (KB)
44100 Excellent 648 No
22050 Good 342 No
11025 Ok 176 No
8192 Ok 132 No
4096 Bad 68 Yes
2048 Bad 36 Yes
1024 Bad 20 Yes
NED University of Engineering & Technology
Department of _____________________ Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date
NED University of Engineering & Technology
Department of Electrical Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date
LAB SESSION 02

OBJECTIVE:

To observe the quantization effects on sampled signals and to understand how quantization leads
to quantization error. In this lab, we will investigate the influence of the number of quantization
levels on the quality of digitized signal. Method of selection of ADC is also a part of this lab session.

THEORY:
Everything stored on a computer is discrete time discrete valued signal. Because computer has finite
number of registers and each register is a finite length register. We take too many samples to give
the ‘effect’ of continuous time signals. But actually they are discrete time. We also take very fine
resolution of amplitude axis to give the effect of continuous valued signal but due to finite word
length of the computer register, the stored variables are already quantized. This lab aims to explain
the quantization effects in a computer.
Regardless of the medium (audio or image), the digitization of real world analog signal usually
involves two stages: sampling, i.e. the measurement of signal at discretely spaced time
intervals, and quantization, i.e. the transformation of the measurements (amplitudes) into
finite-precision numbers (allowed discrete levels), such that they can be represented in
computer memory. Quantization is a matter of representing the amplitude of individual
samples as integers expressed in binary. The fact that integers are used forces the samples to
be measured in a finite number of bits (discrete levels). The range of the integers possible is
determined by the bit depth, the number of bits used per sample. The bit depth limits the
precision with which each sample can be represented.

Bit Depth:

Within digital hardware, numbers are represented by binary digits known as bits—in fact, the
term bit originated from the words Binary digit. A single bit can be in only one of two possible
states: either a one or a zero. When samples are taken, the amplitude at that moment in time must
be converted to integers in binary representation. The number of bits used to represent each
sample, called the bit depth (bits/sample) or sample size, determines the precision with which
the sample amplitudes can be represented. Each bit in a binary number holds either a 1 or a 0. In
digital sound, bit depth affects how much you have to round off the amplitude of the wave when
it is sampled at various points in time
The number of different values that can be represented with b-bit is 2b .The largest decimal
number that can be represented with an b-bit binary number is 2b - 1. For example, the decimal
values that can be represented with an 8-bit binary number range from 0 to 255, so there are
256 different values (levels of ADC). A bit depth of 8 allows 2 8=256 different discrete levels
at which samples can be approximated or recorded. Eight bits together constitute one byte. A
bit depth of 16 allows 2 16 = 65,536 discrete levels, which in turn provides much higher
precision than a bit depth of 8.
The number of bits in a data word is a key consideration. The more bits used in the word, the better
the resolution of the number, and the larger the maximum value that can be represented. Some
computers use 64-bit words. Now, 264 is approximately equal to 1.8 x 1019—that's a pretty large
number. So large, in fact, that if we started incrementing a 64-bit counter once per second at the
beginning of the universe (≈20 billion years ago), the most significant four bits of this counter
would still be all zeros today.
To simplify the explanation, take an example of ADC with a bit depth of 3, 2 3 = 8
quantization levels ranging from -4 to 3 are possible in signed magnitude representation. For
bipolar ADCs (or signed magnitude representation), by convention, half of the quantization
levels are below the horizontal axis (that is 21, of the quantization levels). One level is the
horizontal axis itself (level 0), and 2b-1 − 1levels are above the horizontal axis.Note that since
one bit is used for the signed bit (in 2-complementformat), the largest magnitude corresponds
to 2^(b -1 ). (not 2b). When a sound is sampled, each sample must be scaled to one of the 8
discrete levels. However, the samples in reality might not fall neatly onto these levels. They
have to be rounded up or down by some consistent convention.

QUANTIZATION ERROR:

The samples, which are taken at evenly-spaced points in time, can take on the values only
at the discrete quantization levels to store on our computer. Therefore quantization leads
to a loss in the signal quality, because it introduces a “Quantization error”. Quantization
error is sometimes referred to as '"Quantization noise". Noise can be broadly defined as
part of an audio signal that isn’t supposed to be there. However, some sources would argue
that a better term for quantization error is "distortion", defining distortion as an unwanted
part of an audio signal that is related to the true signal.
The difference between the quantized samples and the original samples constitutes
quantization error or rounding error (if round-off method is used). Xe(n) = Xq(n) − x(n).
The lower the bit depth, the more values potentially must be approximated (rounded),
resulting in greater quantization error
To calculate the required bit depth of ADC i.e. bits/sample, there are two important
points which we must have to consider:
a) How much noise is already present in the analog signal?
b) How much more noise can be tolerated in the digital
signal? Signal-to -noise-ratio- SNR (of analog signal)
Before looking at SNR specifically in the context of digital imaging and sound, let's
consider the general definition. Signal-to-noise ratio can generally be defined as the ratio
of the meaningful content of a signal versus the associated background noise.

SNR = 10log10 (Px /Pe )


Where, Pxand Pe are average power of the analog signal and noise signal respectively.
A signal is any type of communication – something a person says to you, a digital
signal sending an image file across a network, a message posted on an electronic
bulletin board, a piece of audio being played from a cassette, etc. The noise is the
part of the message that is not meaningful; in fact, it gets in the way of the message
intended in the communication. You could use the term signal-to-noise ratio to
describe communications in your everyday life. If you know someone who talks a
lot but doesn't really convey a lot of meaning, you could say that he or she has a
low signal-to-noise ratio. Web-based bulletin board and chat groups are sometimes
described as having a low SNR – there may be quite a few postings, but very much
meaningful content. In these first two examples, the noise consists of all the empty
"filler" words. In the case of a digital signal sent across a network, the noise is the
electronic degradation of the signal. On a piece of audio played from cassette, the
noise could be caused by damage to the tape or mechanical imperfections in the
cassette player.
In analog data communication (analog signals), the signal-to-noise ratio is defined
as the ratio of the average power in the signal versus the power in the noise level.
In this context, think of a signal being sent over a network connection compared
to the extent to which the signal is corrupted. This is related to the genera l usage
of the term described above. This usage of the term SNR applies to analog signals.
SIGNAL-TO-QUANTIZATION-NOISE-RATIO- SQNR (OF ADC):
Using finite word lengths prevents us from representing values with infinite precision, increases
the background noise in our spectral estimation techniques etc. The amount of error implicit in a
chosen bit depth can be measured in terms of the signal-to-noise ratio (SNR).
For a digitized image or sound, the signal-to-noise ratio is defined as the ratio of the maximum
sample value versus the maximum quantization error. In this usage of the term , the ratio
depends on the bit depth chosen for the signal. Any signal encoded with a given bit depth will
have the same ratio. This can also be called signal-toquantization-noise ratio (SQNR), but you
should be aware that in many sources the term signal-to-noise ratio is used with this meaning
as well. (Henceforth, we'll use the term SQNR to distinguish this measurement from SNR.)
Practical A/D converters are constrained to have binary output words of finite length.
Commercial A/D converters are categorized by their output word lengths, which are normally
in the range from 8 to 16 bits. There is no infinite bit ADC. So whenever we will digitize our
signal, we will always have a quantization error. Quantization error represents the quality of
quantization process but the total error may also turn out to be zero, so signal-toquantization-
noise-ratio (SQNR) is used to describe the quality of quantization process and it can be defined
as

SQNRA/D = 10 log 10(Px /Pe)


Where, Px~and Pe are average power of the DTCV (sampled) signal and quantization error
signal respectively.

PROCEDURE:

1. Simulate a DTCV sinusoid of 1/50 cycles/sample with length of the signal be 500.
2. Choose the no. of significant digits for round-off and apply to the signal generated above.
3. Compute the error signals and SQNR
4. Explore and observe.

STEPS:

1. Make a folder at desktop and name it as your current directory within MATLAB.
2. Open M-file editor and write the following code:

clear all;
close all;
clc;
fd1 = 1/50;
n = [0 : 499 ];

q=input('No. of Digits after decimal points to be retained (0-9): ');


x1 = cos(2*pi*fd1*n);
Px1 = sum(abs(x1).^2)/length(x1);
x1q = round(x1*10^q)/10^q;
x1e = x1 -x1q;
Pe1 = sum(abs(x1e).^2)/length(x1e);

SQNR = 10*log10(Px1/Pe1);
disp(['The Signal to Quantization Noise Ratio is: ' num2str(SQNR) '
dB.' ]);
figure,
subplot(2,1,1);
plot(n,x1,n,x1q);
xlabel('indices');
ylabel('Amp');
xlim([0 49]);
ylim([-1.1 1.1]);
legend('DTCV','DTDV');

subplot(2,1,2);
plot(n,x1e);
xlabel('indices');
ylabel('Error');
xlim([0 49]);

3. Save the file as P021.m in your current directory and run it.

Explore and take notes.


Now modify the above code as follows and save as another file P022.m.

clear all;
close all;
clc;
fd1 = 1/50;
n = [0 : 499 ];
q = [0 : 10];

% No. of Digits after decimal points to be retained for num = 1 :


length(q)
x1 = cos(2*pi*fd1*n);
Px1 = sum(abs(x1).^2)/length(x1);
x1q = round(x1*10^q(num))/10^q(num);
x1e = x1 -x1q;
Pe1 = sum(abs(x1e).^2)/length(x1e);
SQNR(num) = 10*log10(Px1/Pe1);
end

figure,
plot(q,SQNR);
xlabel('Significant Digits');
ylabel('SQNR (dB)');
xlim([q(1) q(end)]);

1. Before hitting the ‘run’, just try to understand what the code is doing and try to link it with
the previous code.
2. Now ‘run’ the file and observe the results.

RESULT:

Explain (write) in your own words the cause and effects of what you just saw.

LAB TASKS:

1. Effects of Quantization with variable precision levels


Simulate a DTCV sampled composite signal of 𝑓𝑑1=125 samples/sec and
𝑓𝑑2=150 samples/sec with length of the signal be 250 samples.
Take the desired number of significant digits from user as an input. Then choose the method of
Quantization (round-off, floor & ceil) and apply to the signal generated above.
Compute the quantization error signals and SQNR.

2. Simple sinusoid quantized to various bits per sample


Generate a 100 Hz sinusoid sampled at 10000 samples/sec and quantized at 1_bit/sample.
Now increase the bit depth for various numbers of bits per sample (2, 3, 4, 5, 6, 7, 8) and attach
plots. You can use two column format for plotting (but the diagrams should be visible).

3. Audio signal quantization to various bits per sample


Use your recorded voice in last session and quantize it at 1 bit /sample.
Change bit depth to 2,3,4 and then listen and take notes of your observations.
Decide no. of bits for audio until quality stops improving.
DSP LAB TASKS
Roll No. 26

Lab Session 2
1. Effects of Quantization with variable precision levels
Simulate a DTCV sampled composite signal of 𝑓𝑑1=125 samples/sec and 𝑓𝑑2=150 samples/sec with
length of the signal be 250 samples. Take the desired number of significant digits from user as an
input. Then choose the method of Quantization (round-off, floor & ceil) and apply to the signal
generated above. Compute the quantization error signals and SQNR.

Matlab Code:
clear all; close all; clc;
N = 250;
fd = 1/125;
n = 0:249;
q = input('No. of Digits after decimal points to be retained (0-9): ');
x = cos(2*pi*fd*n);
Px = sum(abs(x).^2)/N;
a = input('Select the method of quantization, press 1 for round-off, 2 for
floor, and 3 for ceil: ');
if a == 1
xq = round(x*10^q)/10^q;
elseif a == 2
xq = floor(x*10^q)/10^q;
elseif a == 3
xq = ceil(x*10^q)/10^q;
end
xe = xq - x;
Pe = sum(abs(xe).^2)/N;
SQNR = 10*log10(Px/Pe);
disp(['The Signal to Quantization Noise Ratio is: ' num2str(SQNR) ' dB.']);
figure;
subplot(2,1,1);
stem(n, x, 'filled');
hold on;
stem(n, xq, 'r', 'filled');
grid;
xlabel('indices');
ylabel('Amp');
xlim([0 49]);
ylim([-2.1 2.1]);
legend('DTCV', 'DTDV');

subplot(2,1,2);
plot(n, xe, 'k', 'Linewidth', 2);
xlabel('indices');
ylabel('Error');
xlim([0 49]);
DSP LAB TASKS
Roll No. 26

For fd = 1/125 cycles/sample:


No. of Digits after decimal points to be retained (0-9): 4

Select the method of quantization, press 1 for round-off, 2 for floor, and 3 for ceil: 3

The Signal to Quantization Noise Ratio is: 81.8205 dB.

For fd = 1/150 cycles/sample:


No. of Digits after decimal points to be retained (0-9): 4

Select the method of quantization, press 1 for round-off, 2 for floor, and 3 for ceil: 2

The Signal to Quantization Noise Ratio is: 81.7293 dB.


DSP LAB TASKS
Roll No. 26

Comments: When a signal is quantized, three methods of floor, round-off and ceil are employed
for approximation. Due to which, some errors are generated. Here in this code we have asked the user
for the number of decimal places to approximate the values and the method for approximation.

It is observed that the SQNR is higher for round-off as it generates the least error. SQNR varies inversely
with the power of error signal.

2. Simple sinusoid quantized to various bits per sample


Generate a 100 Hz sinusoid sampled at 10000 samples/sec and quantized at 1_bit/sample.
Now increase the bit depth for various numbers of bits per sample (2, 3, 4, 5, 6, 7, 8) and
attach plots. You can use two column format for plotting (but the diagrams should be
visible).
Matlab Code:

Method used for Quantization: Round off


No. of bits = 1 No. of bits = 2

No. of bits = 3 No. of bits = 4

No. of bits = 5 No. of bits = 6


DSP LAB TASKS
Roll No. 26

No. of bits = 7 No. of bits = 8

Comments: It can be observed as the bit depth is increased, the approximation of the values got
quite a lot better. A very minimal amount of error occurs at higher bit depths such as 7 or 8.

3. Audio signal quantization to various bits per sample


Use your recorded voice in last session and quantize it at 1 bit /sample. Change bit depth
to 2, 3, 4 and then listen and take notes of your observations. Decide no. of bits for audio
until quality stops improving.
Matlab Code:
clear all, close all, clc;

file_path = 'D:\quick access\5th semester\DSP\output44.1k.wav';


[x, Fs] = audioread(file_path);
bit_depths = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

% Listening and note-taking


for i = 1:length(bit_depths)
% Quantize the audio signal
x_quantized = quantize_audio(x, bit_depths(i));

% Save quantized audio to a file


output_file = sprintf('quantized_audio_%dbits.wav', bit_depths(i));
audiowrite(output_file, x_quantized, Fs);
end

function x_quantized = quantize_audio(x, num_bits)


% Scale the audio signal to the range [-1, 1]
x_scaled = x / max(abs(x));

% Quantize to the specified number of levels


num_levels = 2^num_bits;
x_quantized = round(x_scaled * (num_levels - 1)) / (num_levels - 1);

% Rescale the signal back to its original range


x_quantized = x_quantized * max(abs(x));
end
DSP LAB TASKS
Roll No. 26

Comments: The voice recorded at 44.1k Hz sampling rate is quantized at different number of
bits.

Bit Depth Remarks


1 Voice totally lost. Only a spark was heard.
2 60% of the voice captured. Remaining lost
3 Whole voice is captured. But still a lot of Noise.
4 The Noise starts to reduce now.

The voice quality stopped improving at higher number of bit depths such as 8 and so on.
NED University of Engineering & Technology
Department of _____________________ Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date
NED University of Engineering & Technology
Department of Electrical Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date
LAB SESSION 03
OBJECTIVE:

To study impulse response, observe convolution technique in signal processing, and verify
different properties like causality, commutative, distributive and associative properties.

THEORY:

1. Convolution is given as :y(n) = x(n)*h(n) =

i.e.one can compute the output y(n) to a certain input x(n) when impulse response h(n) of
that system is known. Convolution holds commutative property.

2. The length of the resulting convolution sequence is N+M-1,where N and M are the
lengths of two convolved signals respectively.

3. In causal system, the outputs only depend on the past and/or present values of inputs and
NOT on future values. This means that the impulse response h(n) of a causal system will
always exist only for n≥ 0.

PROCEDURE:

1. We have the impulse response of a system as h(n) = { 3,2,1,-2,1,0,-4,0,3}



2. For x(n)={1,-2,3,-4,3,2,1}

STEPS:
1. Make a folder at desktop and name it as your current directory within MATLAB.
2. Open M-file editor and write the following code:

clear all;
close all;
clc;
h = [3 2 1 -2 1 0 -4 0 3]; % impulse response
org_h = 1; % Sample number where origin exists
nh = [0 : length(h)-1]- org_h + 1;
x = [1 -2 3 -4 3 2 1]; % input sequence
org_x = 1; % Sample number where origin exists
nx = [0 : length(x)-1]- org_x + 1;
y = conv(h,x);

ny = [nh(1)+ nx(1) : nh(end)+nx(end)];


figure,

subplot(3,1,1),
stem(nh,h);
xlabel('Time index n');
ylabel('Amplitude');
xlim([nh(1)-1 nh(end)+1]);
title('Impulse Response h(n)');
grid;

subplot(3,1,2),
stem(nx,x);
xlabel('Time index n');
ylabel('Amplitude');
xlim([nx(1)-1 nx(end)+1]);
title('Input Signal x(n)');
grid;

subplot(3,1,3)
stem(ny,y);
xlabel('Time index n');
ylabel('Amplitude');
xlim([ny(1)-1 ny(end)+1]);
title('Output Obtained by Convolution');
grid;

1. Save the file as P031.m in your current directory and ‘run’ it.
2. Calculate the length of input signal (N) and impulse response (M) used in above task?
3. Calculate the length of the output sequence and verify the result with N+M-1
4. Try to learn, explore the code and make notes.
5. Now modify the above code such that h(n)= {3,2, 1, -2,1,0,-4,0,3}(origin is shifted) and
check for causality.

RESULT:
EXERCISE:

1. What will happen if we input x(n)={0,0,1,0,0} into the above system.



2. Can you prove the commutative property of the convolution?

3. Modify the code to prove Associative and Distributed properties of the convolution.

4. Convolve your recorded sound with drumloop.wav. Note your observation

a) Plot the output.


b) Listen the output
DSP LAB TASKS
Roll No. 26

Lab Session 3
1. What will happen if we input x(n)={0,0,1,0,0} into the above system.

clear all, clc, close all;
h = [3 2 1 -2 1 0 -4 0 3];
org_h = 1;
nh = (1:length(h)) - org_h;
x = [0 0 1 0 0];
org_x = 1;
nx = (1:length(x)) - org_x;
y = conv(h, x);
ny = nh(1) + nx(1):nh(end) + nx(end);
figure;
%plotting impulse response
subplot(3, 1, 1);
stem(nh, h, 'filled', 'k');
xlabel('Time index(n)'), ylabel('Amplitude');
xlim([nh(1)-1 nh(end)+1]);
title('Impulse response h(n)'), grid;
%plotting input signal
subplot(3, 1, 2);
stem(nx, x, 'filled', 'g');
xlabel('Time index(n)'), ylabel('Amplitude');
xlim([nx(1)-1 nx(end)+1]);
title('Input signal x(n)'), grid;
%ploting output signal
subplot(3, 1, 3);
stem(ny, y, 'r', 'filled');
xlabel('Time index(n)'), ylabel('Amplitude');
xlim([ny(1)-1 ny(end)+1]);
title('Output y(n)'), grid;
DSP LAB TASKS
Roll No. 26

The system analyzed in the lab generates the following output to the input signal
x(n)={0,0,1,0,0} :

y(n) = [0, 0, 3, 2, 1, −2, 1, 0, −4, 0, 3, 0, 0]

2. Can you prove the commutative property of the convolution?
Matlab Code:
clear all, close all, clc;
% Impulse response
h = [2, 0, -3, 4];
% Input signal
x = [1, 2, 3, 4];
% Convolving h(n) with x(n)
y1 = conv(h, x);

% Convolving x(n) with h(n)


y2 = conv(x, h);

% Plotting the results


figure;

subplot(2, 1, 1);
stem(y1, 'filled', 'k');
xlabel('Time index(n)'), ylabel('Amplitude');
title('y1(n) = h(n)*x(n)'), grid on;

subplot(2, 1, 2);
stem(y2, 'filled', 'k');
xlabel('Time index(n)'), ylabel('Amplitude');
title('y2(n) = x(n)*h(n) '), grid on;
DSP LAB TASKS
Roll No. 26

Comments: It can be observed that both the outputs are same whether you convolve
x(n) with h(n) or h(n) with x(n) proving the commutative property of convolution.

3. Modify the code to prove Associative and Distributed properties of the


convolution.
close all, clear all; clc;
% Define three input sequences
x = [1, 2, 3, 4];
h = [1, 4, 3];
g = [1, 1, 4];
% commutative property
y1 = conv(x, h); % x * h
y2 = conv(h, x); % h * x
% associative property
ap_lhs = conv(conv(x, h), g);
ap_rhs = conv(x, conv(h, g));
% distributive property
dp_lhs = conv(x, h + g);
dp_rhs = conv(x, h) + conv(x, g);
% Plot the comparisons
figure;
% Commutative Property Comparison
subplot(2, 1, 1);
stem(y1, 'filled', 'r');
title('y(n) = x(n) * h(n)');
subplot(2, 1, 2);
stem(y2, 'filled');
title(' y(n) = h(n) * x(n)');
suptitle('Commutative Property');
% Associative Property Comparison
figure;
subplot(2, 1, 1);
stem(ap_lhs, 'filled','k');
title('y(n) = (x(n) * h(n)) * g(n)');
subplot(2, 1, 2);
stem(ap_rhs, 'filled', 'b');
title('y(n) = x(n) * (h(n) * g(n))');
suptitle('Associative Property');
% Distributive Property Comparison
figure;
subplot(2, 1, 1);
stem(dp_lhs, 'filled');
title('y(n)= x(n) * (h(n) + g(n))');
subplot(2, 1, 2);
stem(dp_rhs, 'filled', 'r');

Comments: The laws of association and


distribution were further applied to the previous
code. It can be observed that the convolution
follows the associative and distributive properties
too. The output is similar for every case.
DSP LAB TASKS
Roll No. 26

4. Convolve your recorded sound with drumloop.wav. Note your observation


a) Plot the output.
b) Listen the output.
Matlab Code:
clear all; close all; clc;
%using audioread command to access .wav files
[x1, Fs1] = audioread('D:\quick access\5th semester\DSP\kar98k.wav');
[x2, Fs2] = audioread('D:\quick access\5th semester\DSP\output44.1k.wav');
x1 = x1(:, 1);
x2 = x2(:, 1);
org_x1 = 1;
nx1 = [1:length(x1)] - org_x1;
org_x2 = 1;
nx2 = [1:length(x2)] - org_x2;
% Perform convolution
z = conv(x1, x2);
nxz = [nx1(1) + nx2(1):
nx1(end) + nx2(end)];
% Plotting
figure;
subplot(3, 1, 1),
plot(nx1, x1, 'r');
xlabel('Time index (n)'),
ylabel('Amplitude');
xlim([nx1(1) - 1, nx1(end) +
1]),
title('Shotgun'),
grid on;

subplot(3, 1, 2),
plot(nx2, x2, 'g');
xlabel('Time index (n)'),
ylabel('Amplitude');
xlim([nx1(1) - 1, nx1(end) +
1]);
title('audio'), grid on;

subplot(3, 1, 3)
plot(nxz, z, 'b');
xlabel('Time index (n)'),
ylabel('Amplitude');
xlim([nx1(1) - 1, nx1(end) + 1]);
title('Convolved Output'), grid on;
% listening to the voice
sound(z, Fs2);
% Saving the convolved audio
% Normalize the signal z to the range [-1, 1]
z_normalized = z / max(abs(z));
audiowrite('D:\quick access\5th semester\DSP\conv.wav', z_normalized, Fs2);

Comments: My normal voice which was captured in my room was convolved with the
impulse response i.e. a shotgun sound. The convolved output felt like the voice was recorded in
an auditorium. Following are the plots obtained from matlab.
NED University of Engineering & Technology
Department of _____________________ Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date
NED University of Engineering & Technology
Department of Electrical Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date
LAB SESSION 04

OBJECTIVE:

To study discrete time correlation and apply it to real data to observe the correlation
between two signals.

THEORY:

1. Correlation is given as where ‘l’ is the lag. This is called cross-correlation and it
gives the magniyude and location of similarity between two signals. The correlation
between x(n) and y(n) . It is given as:

2. Generally rxy(l) = ryx(l). These two are the same when x(n) and y(n) are the same signals
or when x(n) and y(n) are even symmetric signals .

3. The length of the resulting correlation sequence is N+M-1, where N and M are the
lengths of the two signals.

4. Correlation may also be computed using convolution algorithm with a modification that
we need to fold one of the signals before applying convolution.
Mathematically, rxy(n)= x(n) * y(-n)

STEPS:

1. Generate two sinusoids of length 10 and fd = 0.1 with variable phase.


2. Apply correlation and check for certain properties such as magnitude and location of
maximum correlation with varying phases.

PROCEDURE:

1.Make a folder at desktop and name it as your current directory within MATLAB. -
2.Open M-file editor and write the following code: )

clear all;
close all;
clc;
n = [0:9];
ph1 = 0;
ph2 = 0;
x = sin(2*pi*0.1*n + ph1);
org_x = 1;
nx = [0 : length(x)-1]- org_x + 1;

y = sin(2*pi*0.1*n + ph2);
org_y = 1;
ny = [0 : length(y)-1]- org_y + 1;

rxy = xcorr(x,y);
nr = [nx(1)-ny(end) : nx(end)-ny(1)];

[maxR indR] = max(rxy);

disp(['The correlation at lag zero is: ' num2str(rxy(find(nr==0)))


'.']);
disp(['The maximum correlation is at lag ' num2str(nr(indR)) '.']);
|
figure,
subplot(3,1,1),
stem(nx,x);
xlabel('Time index n');
ylabel('Amplitude');
xlim([nx(1)-1 nx(end)+1]);
title('Signal x(n)');
grid;

subplot(3,1,2),
stem(ny,y);
xlabel('Time index n');
ylabel('Amplitude');
xlim([ny(1)-1 ny(end)+1]);
title('Signal y(n)');
grid;

subplot(3,1,3)
stem(nr,rxy);
xlabel('Time index n');
ylabel('Amplitude');
xlim([nr(1)-1 nr(end)+1]);
title('Cross Correlation');
grid;
Save the file as P041.m in your current directory and ‘run’ it.

Learn the specific logical bits of the code and make notes

Now modify the phase of the second signal to pi/2 (it will make it cosine) and observe the
correlation at lag zero. Modify the phase again to ‘pi’ and observe.

1. Check for auto-correlation (ph1 = ph2) that the lag zero value gives the energy of the
Signal.
2. Observe that the commutative property does not hold.

RESULT:

Please write in exercise book.

EXERCISE:

1. Now modify the phase of the second signal to pi/2 (it will make it cosine)and observe the
correlation at lag zero.
2. Modify the phase again to ‘pi’ and observe.
3. Check for auto-correlation (ph1 = ph2) that the lag zero value gives the m energy of the
signal.
4. Observe that the commutative property does not hold.
5. Modify the code, such that the correlation is obtained using convolution command.
6. Calculate correlation between voltages of any two phases of a 10HP motor Using the data
given below. First use Ms. Excel to copy data and then calculate correlation.
Voltage A Min Voltage B Min Voltage C Min
189.358 153.917 195.735
189.175 159.719 201.877
188.783 161.575 186.718
188.757 172.186 187.659
176.995 173.206 205.876
180.472 176.865 204.831
180.524 176.917 192.494
180.262 189.28 199.839
181.778 189.828 211.887
179.975 189.462 211.94
178.642 189.253 212.462
180.315 188.94 193.749
180.707 190.377 200.492
180.262 190.194 201.433
180.628 190.064 202.635
180.315 189.907 200.701
179.635 189.541 203.289
179.243 189.567 202.635
179.4 189.619 200.989
180.576 189.044 197.591
180.837 189.123 199.865
180.184 189.332 201.093
180.08 189.097 201.041
177.675 189.044 199.656
175.297 189.018 198.558
173.99 189.123 204.595
Lab 4 Tasks

Code for tasks 1-3:


clear all;
close all;
clc;
n = [0:49];
ph1 = 0;
ph2 = 0;
x = sin(2*pi*0.1*n + ph1);
origin_x = 1;
nx = [1:length(x)]-origin_x;
y = sin(2*pi*0.1*n + ph2);
origin_y = 1;
ny = [1:length(y)]-origin_y;
[rxy l]=xcorr(x,y);
[maxR indR] = max(rxy);
disp(['The correlation at lag zero is: ' num2str(rxy(l==0)) '.']);
disp(['The maximum correlation is at lag ' num2str(l(indR)) '.']);
norm_corr=rxy/max(abs(rxy));
perct_corr=norm_corr*100
figure

subplot(4,1,1), stem(nx,x,'filled','b')
xlabel('Time index (n)'), ylabel('Amplitude')
xlim([nx(1)-1 nx(end)+1])
title('Signal x(n)'), grid
subplot(4,1,2), stem(ny,y,'filled','r')
xlabel('Time index (n)') ,ylabel('Amplitude')
xlim([ny(1)-1 ny(end)+1])
title('Signal y(n)'),grid
subplot(4,1,3),stem(l,rxy,'filled','k')
xlabel('Lag index (l)'),ylabel('Correlated Output')
title('Correlation'),grid
subplot(4,1,4),stem(l,norm_corr,'filled','k')
xlabel('Lag index (l)'), ylabel('Normalized Correlated Output')
title('Normalized Correlation'),grid;

1. Now modify the phase of the second signal to pi/2 (it will make it cosine) and observe the
correlation at lag zero.

2. Modify the phase again to ‘pi’ and observe.

3. Check for auto-correlation (ph1 = ph2) that the lag zero value gives the m energy of the signal.

At phase 2 = pi/2:
The correlation at lag zero is: 4.9127e-15.

The maximum correlation is at lag 2.


Tasks Lab Session 4

Comments: Very little


amount of correlation
observed at lag 2
caused by 90 degrees
phase difference.

At phase 2 = pi:

Comments: The two


signals correlates
perfectly at lag 5 as both
the signals are at origin
at lag 5. The negative
sign shows both the
signals are 180 degrees
apart.

The correlation at lag zero is: -25.

The maximum correlation is at lag 5.


Tasks Lab Session 4

At Phase 1 = Phase 2:

Comments: Both the


signals are similar so
the correlates perfectly
at any lag.

The correlation at lag zero is: 25.

The maximum correlation is at lag 0.

4. Observe that the commutative property does not hold.


%rxy!=ryx
clear all;close all;clc;
n = [0:49];
phi_1 = 0;
phi_2 = 0;
x = sin(2*pi*0.1*n + phi_1);
origin_x = 1;
nx = [1:length(x)]-origin_x;
y = cos(2*pi*0.1*n + phi_2);
origin_y = 1;
ny = [1:length(y)]-origin_y;
[rxy , c1]=xcorr(x,y);
[ryx , c2]=xcorr(y,x);
figure,
subplot(2,1,1)
stem(c1,rxy,'filled','g')
xlabel('Lag index');
ylabel('Correlated rxy
Output')
title('Correlation')
grid on;
subplot(2,1,2)
stem(c2,ryx,'filled','g')
Tasks Lab Session 4
Comments: Although correlation looks like
doing convolution but it does not hold the
xlabel('Lag index');, commutative property as can be seen in
ylabel('Correlated ryx Output')
output waveforms
title('Correlation')
sgtitle('Commutative doesnt hold')
grid on;

5. Modify the code, such that the correlation is obtained using convolution command.
% rxy(n)=x(n)*y(-n)
clc;clear all;close all;
n = [0:49];
ph1 = 0;
ph2 = 0;
x = sin(2*pi*0.1*n + ph1);
origin_x = 1;
nx = [1:length(x)]-origin_x;
y = sin(2*pi*0.1*n + ph2);
origin_y = 1;
ny = [1:length(y)]-origin_y;
z=fliplr(y);
rxy_1=conv(x,z);
[rxy_2 l]=xcorr(x,y);
subplot(2,1,1)
stem(l,rxy_1,'filled','k')
xlabel('Lag index');
ylabel('Correlated Output')
title('Using Convolution')
grid on;
subplot(2,1,2)
stem(l,rxy_2,'filled','m')
xlabel('Lag index');
ylabel('Correlated Output')
title('Using Correlation') Comments: The correlation code is modified using a flip
sgtitle('Correlation using Convolution') command in the code. So the correlation becomes
grid on;
exactly like convolution as can be veified from the output
6. Calculate correlation between voltages of any two phases of a 10HP motor using the data given
below. First use Ms. Excel to copy data and then calculate correlation.
clc;clear all;close all;
[numbers, strings, raw] =
xlsread('D:\Quickaccess\5th sem\DSP\Lab4Task6');
numbers_1 = numbers(:,1);
numbers_3 = numbers(:,3);
org_num1 = 1;
num1_x = [ 1:length(numbers_1) ] - org_num1 ;
orgin_num3 = 1;
num3_x = [ 1:length(numbers_3) ] - orgin_num3 ;
[values,indices] = xcorr(numbers_1,numbers_3);
[maxVal,position] = max(values);
disp(['The correlation at lag zero is: '
num2str(values(indices==0)) '.']);
disp(['The maximum correlation is at lag '
num2str(indices(position)) '.']);
normalized_correlation=values/max(abs(values));
percent_correlation=normalized_correlation*100;
Tasks Lab Session 4

subplot(5,1,1),stem(num1_x,numbers_1,'filled','k'),xlabel('Time index (n)');


ylabel('Voltage'),xlim([num1_x(1)-1 num1_x(end)+1]),
title('Voltage A'),grid on;
subplot(5,1,2),stem(num3_x,numbers_3,'filled','r'), xlabel('Time index (n)');
ylabel('Voltage'),xlim([num3_x(1)-1 num3_x(end)+1]),title('Voltage C')
grid on;
subplot(5,1,3),stem(indices,values,'filled','g'),xlabel('Indices');
ylabel('Correlation Output'),xlim([indices(1)-1 indices(end)+1])
title('Correlation'), grid on;
subplot(5,1,4), stem(indices,normalized_correlation,'filled','b');
xlabel('Indices'), ylabel('Normalized Correlation Output')
xlim([indices(1)-1 indices(end)+1]), title('Normalized Correlation')
grid on;
subplot(5,1,5), stem(indices,percent_correlation,'filled','Color',[0 1 1]);
xlabel('Indices'), ylabel('Percentage Correlation Output')
xlim([indices(1)-1 indices(end)+1]), title('Percentage Correlation')
grid on;

Comments: Correlation between the phase A and phase C was observed. The correlation is
maximum at starting indices but decreases as we move higher up the order.
LAB SESSION 05

OBJECTIVE:

To study the computer implementation of Discrete FourierT transform and Inverse Fourier
Transform using Twiddle factor.

THEORY:

The formulas for the DFT and IDFT are given as


∑𝑁−1 𝑘𝑛
X(K) = 𝑛=0 𝑥(𝑛) 𝑊𝑁 ; k=0,1,……N-1

1 −𝑘𝑛
X(n) = ∑𝑁−1
𝑛=0 𝑋(𝑘) 𝑊𝑁 ; k=0,1,……N-1
𝑁

−𝑗2𝛱
Where by definition WN = 𝑒 𝑁

Which is an Nth root of unity. Where WN is called Twiddle Factor , also

[WN] = [𝑒 −𝑗2𝛱/𝑁 ]kn

𝑘𝑛
W = 𝑒 −𝑗2𝛱𝑘𝑛/𝑁
𝑁

DFT analysis equation in matrix form is

𝑘𝑛
XN=[ W ]xN
𝑁

DFT synthesis equation in matrix form is

𝑘𝑛 -1
xN= [W ] XN
𝑁

PROCEDURE:
TASK
Compute 4 point DFT of x(n)= ( 1,2,3,0).

STEPS
1.Generate given sequence in Matlab .
2.Take N-=4 to calculate 4-point DFT.
3.Define 0: N-1 point vector for time and frequency samples.
4.Define W matrix and then use DFT analysis equation to compute DFT.

close all,
clear all;
clc;
x=[1 ,2 ,3 ,0];
N=4;
n=[0:1:N-1];
k=[0:1:N-1];

WN=exp(-j*2*pi/N);

nk=n'*k;

WNnk=WN.^nk;

Xk=x*WNnk

LAB TASK

Prove DFT synthesis equation using DFT output generated from lab task.
Lab 5 tasks
1) Prove DFT synthesis equation using DFT output generated from lab task.
x = [1, 2, 3, 0];
N = 4;
Fs = 100;
n = [0:1:N-1];
k = [0:1:N-1];
WN = exp(-j*2*pi/N);
kn = n' * k;
WNkn = WN.^kn;
Xk = x * WNkn;
% DFT synthesis equation
x_synthesized = zeros(1, N);
for nn = 0:N-1
x_synthesized(nn+1) = (1/N)
* sum(Xk .* exp(j*2*pi/N * k *
nn));
end
% Plot the original and
synthesized signals
figure;
subplot(211)
stem(n, x, 'r',
'MarkerFaceColor', 'r')
% Original signal in red
title('Original Signal')
xlabel('n')
ylabel('x[n]')
subplot(212)
stem(n, real(x_synthesized), 'b', 'MarkerFaceColor', 'b')
% Synthesized signal in blue Comments: Proving DFT synthesis equation means to reconstruct
title('Synthesized Signal') the given discrete signal from its frequency components. It can be
xlabel('n') seen here that a discrete signal was taken and DFT was applied to
ylabel('x_synth[n]'); break it into its frequency components and then for loop was
applied for summation of that DT sinusoids frequency components
to obtain the original signal.

2) Forward DFT using matrices. Develop a MATLAB code to find the Forward DFT output of the
following time domain sequence by using DFT equation in matrix form. Also plot the
magnitude and phase spectrum. Take 𝐹𝑠 = 1000 𝑠𝑎𝑚𝑝𝑙𝑒𝑠⁄𝑠𝑒𝑐 𝑥(𝑛) = {0.3535, 0.3535, 0.6464,
1.0607 , 0.3535, − 1.0607, − 1.3535 , − 0.3535}
close all,clear all;clc;
x=[0.3535, 0.3535, 0.6464, 1.0607, 0.3535, -1.0607, -1.3535 , -0.3535];
N=8; n=[0:1:N-1]; k=[0:1:N-1]; WN=exp(-j*2*pi/N); nk=n'*k; WNnk=WN.^nk;
Xk=x*WNnk, mag_Xk=abs(Xk);, phase_Xk=angle(Xk);
phase_degrees=rad2deg(phase_Xk);
figure;
subplot(2,1,1), stem(n,mag_Xk,'filled','g','LineWidth',1.5)
xlabel('Index(K)'), ylabel('|X(k)|'),title('Magnitude Plot'),grid;
subplot(2,1,2), stem(n,phase_degrees,'filled','k','LineWidth',1.5)
xlabel('Index(K)'),ylabel('?X(k)'),title('Phase Plot'),grid;
Lab 5 tasks

Comments: Forward DFT was


applied through matrix
multiplication and the magnitude
and phase spectrums of the given
time domain signal was
observed.

Output: { -0.0001 + 0.0000i, 0.0000 - 3.9999i, 1.4141 + 1.4144i -0.0000 - 0.0001i, -0.0001 - 0.0000i,

0.0000 + 0.0001i, 1.4141 - 1.4144i, -0.0000 + 3.9999i}

2. Inverse DFT using Matrix inversion Develop a MATLAB code to find the inverse DFT output of the
following frequency domain sequence by
using IDFT equation in matrix form (use
matrix inversion). 𝑋(𝑘) = {0, 4∠ − 90 ∘ ,
2∠45 ∘ , 0 , 0, 0, 2∠ − 45 ∘ , 4∠90 ∘ }
close all,clear all;clc;
%values converted from polar
co-ordinates to rectangular co-
ordinates
Xk=[0,-4i ,1.414+1.414i, 0 , 0,
0, 1.414-1.414i ,4i];
N=8;
n=[0:1:N-1];
k=[0:1:N-1];
WN=exp(-j*2*pi/N);
nk=n'*k;
WNnk=WN.^nk;
B=inv(WNnk);
Xk_inv=Xk.';
Xn=(1/N)*(Xk)*B
figure;
Lab 5 tasks
Comments: The same frequency components were
stem(n,Xn,'filled','g','LineWidth',1.5) given as obtained in the previous tasks. Inverse DFT
xlabel('Index(n)'), was applied to reconstruct the signal using matrix
ylabel('x(n)'),
title('Signal in time domain x(n)'), inversion which takes a great deal of time if the
grid; matrix if of higher order.

3. Inverse DFT using Conjugate method Develop a MATLAB code to find the inverse DFT output of the
following frequency domain sequence by using IDFT equation in matrix form (use conjugate method).
𝑋(𝑘) = {0, 4∠ − 90 ∘ , 2∠45 ∘ , 0 , 0, 0, 2∠ − 45 ∘ , 4∠90 ∘ }
close all,clear all;clc;
Xk=[0, -4i, 1.414+1.414i, 0, 0, 0, 1.414-1.414i, 4i];
N=8;
n=[0:1:N-1];
k=[0:1:N-1];
WN=exp(-j*2*pi/N);
nk=n'*k;
WNnk=WN.^nk;
B=conj(WNnk);
Xk_inv=Xk.';
Xn=(1/N)*(Xk)*B
figure;
stem(n,Xn,'filled','g','LineWidth',1.5)
xlabel('Index(n)'),
ylabel('x(n)'),
title('Signal in time domain x(n)'),
grid;

Comments: Conjugate method was applied in this code to avoid matrix


inversion which is quite hectic. Output remains the same.
LAB SESSION 06

OBJECTIVE:
To observe/find different frequency components in an audio signal and plot it with different x_
axes .

THEORY:

PROCEDURE:

1. Load an audio file ‘noisy.wav’ into Matlab.


2. There is a tone added to the speech in this file. The objective is to find the frequency of
this tone.
3. Computing the DFT of this signal;
4. Generating frequency vector in Hz.
5. Displaying the DFT and observing the frequency of the added tone.

STEPS
1. Make a folder at desktop and name it as your current directory within MATLAB.
2. Copy the audio file ‘noisy.wav’ into your current directory.
3. Open M file editor and write the following code:

clear all; clc; close all;


[y,Fs,bits] = wavread('noisy.wav');
Ts = 1/Fs;
n = [0:length(y)-1];
t = n.*Ts; k = n;
Df = Fs./length(y);
F = k.*Df;
Y = fft(y);
magY = abs(Y);
sound(y,Fs);
figure,

subplot(2,1,1);
plot(F,magY);
grid on;
xlim([0 Fs/2]);
xlabel('Frequency (Hz)');
ylabel('DFT Magnitude');
title('Discrete Fourier Transform');

subplot(2,1,2);
plot(F,magY);
grid on;

xlim([0 2000]);
xlabel('Frequency (Hz)');
ylabel('DFT Magnitude');
title('Discrete Fourier
Transform');

4. Save the file as P081.m in your current directory and run it.

RESULT:

Explore and take notes.

EXERCISE:

Use recorded data,


1. Plot different frequencies present in it with
a) x-axis as time
b )x-axis as frequency. (Take FFT and plot).
2. Calculate the amount of energy present in fundamental frequency.
3. Calculate the amount of energy present in different harmonics.
Lab 6 Tasks

1) Use recorded data, 1. Plot different frequencies present in it with a) x-axis as time b )
x-axis as frequency. (Take FFT and plot). 2. Calculate the amount of energy present in
fundamental frequency. 3. Calculate the amount of energy present in different harmonics.
clc; clear; close all;
[data, fs] = audioread('D:\quick access\5th semester\DSP\noisy.wav');
Ts = 1 / fs;
n = (0:length(data) - 1);
t = n * Ts;
Df = fs / length(data);
F = n * Df;
Y = fft(data);
magY = abs(Y);
ang = angle(Y);
sound(data, fs);

subplot(5, 1, 1);
plot(t, data','r');
xlim([0 2]);
xlabel('Time (s)');
ylabel('Amplitude');
title('Original
Signal');
subplot(5, 1, 2);
plot(F, magY, 'r');
grid on;
xlim([0 fs/2]);
xlabel('Frequency
(Hz)');
ylabel('DFT Magnitude');
title('Discrete Fourier
Transform');

subplot(5, 1, 3); Comments: Multiple tasks are achieved in the code. First of all we take
plot(F, magY, 'r'); a recoding also having a little noise. The recording in the time domain
grid on;
was disintegrated into its frequency components by applying. The most
xlim([0 2000]);
xlabel('Frequency (Hz)'); dominant component of frequency is of course the voice of the
ylabel('DFT Magnitude'); speaker. A little noise in the recording also had a considerable effect as
title('DFT - Zoomed In'); can be seen in the DFT waveform. The voice recording was then
cutoff_frequency = 600;
order_of_filter = 11; modified to avoid the noise by setting a cut off frequency to attenuate
normalized_frequency = the noise. The filtered signal and its DFT is then plotted to observe the
cutoff_frequency / (fs / 2); energy of the noise affecting our recording.
[y, x] =
butter(order_of_filter,
normalized_frequency);
filtered_signal = filtfilt(y, x, data);
subplot(5, 1, 4);
plot(t, filtered_signal,'r');
xlim([0 2]);
xlabel('Time (s)');
ylabel('Amplitude');
title('Filtered Signal');
Lab 6 Tasks

subplot(5, 1, 5);
normalized_fft_of_filtered_signal = abs(fft(filtered_signal)) /
length(filtered_signal);
plot(F, normalized_fft_of_filtered_signal,'r');
grid on;
xlim([0 2000]);
xlabel('Frequency (Hz)');
ylabel('DFT Magnitude');
title('DFT of Filtered Signal');

Task-1: Removal of tone from the noisy signal through FFT results

To remove the noisy tone, we can zero-in on noisy tone by looking at the DFT of the noisy signal. Take
Inverse DFT [ifft] of the modified spectra. Listen to the new time-domain signal and see how effectively
the tone noise is removed. Comment on the sound you have just heard. Is the noise completely
removed? Repeat the task with different threshold DFT magnitude values.
clc; clear; close all;
[data, fs] = audioread('D:\quick access\5th semester\DSP\noisy.wav');
Ts = 1 / fs; n = (0:length(data) - 1); t = n * Ts;
Df = fs / length(data); F = n * Df;
Y = fft(data); magY = abs(Y); ang = angle(Y);
% Threshold value for
magnitude spectrum
threshold = 0.5; % You can
adjust this threshold
% Apply thresholding to the
magnitude spectrum
Y_thresh = Y .* (magY >
threshold * max(magY));
% Take the inverse DFT to
obtain the modified signal
modified_signal =
ifft(Y_thresh);
% Play the original and
modified signals
sound(data, fs);
pause(2);
sound(modified_signal, fs);

% Plot the original and


modified signals figure;
subplot(2, 1, 1); plot(t,
data');
xlim([0 2]); xlabel('Time
(s)');
ylabel('Amplitude'); Comments: Since tone is at higher frequency than the
title('Original Signal'); noise and the voice in the recording, at threshold value 0.1
subplot(2, 1, 2); plot(t,
real(modified_signal));
only the tone could be heard. At lower threshold values
xlim([0 2]); xlabel('Time (s)'); the voice started to come back. We are now able to
ylabel('Amplitude'); attenuate the lower frequency components from our
title('Modified Signal'); signal.
Lab 6 Tasks

Task-2: Removal of tone from the noisy signal expression

Write the expression of the tone by zooming in the time domain signal and observing its time period.
Next subtract the samples of the tone from the noisy signal, attach plot and comment on the output.
clc; clear; close all;
[data, fs] = audioread('D:\quick access\5th semester\DSP\noisy.wav');
downsampling_factor = 10;
data_downsampled = data(1:downsampling_factor:end);
t_downsampled = (0:length(data_downsampled)-1) / (fs / downsampling_factor);
% Plot the original signal
t = (0:length(data)-1) /
fs;
figure,
subplot(3, 1, 1);
plot(t, data);
xlabel('Time (s)');
ylabel('Amplitude');
title('Noisy Signal');
zoom_start = 2;
zoom_end = 2.2;
subplot(3, 1, 2);
plot(t, data);
xlim([zoom_start
zoom_end]);
xlabel('Time (s)');
ylabel('Amplitude');
title('Zoomed-in on
Tone');
tone_start = 2.1;
tone_end = 2.2;
tone_period = tone_end -
tone_start;
tone_frequency = 1 /
tone_period;
tone_signal = sin(2 * pi * tone_frequency * t_downsampled);
tone_signal_upsampled = interp1(t_downsampled, tone_signal, t, 'linear');
denoised_signal = data' - tone_signal_upsampled;
sound(denoised_signal,fs)
sound(denoised_signal,fs)
subplot(3, 1, 3);
plot(t, denoised_signal);
xlabel('Time (s)');
ylabel('Amplitude');
title('Denoised Signal');
disp('Tone removal not achieved. Check the plots for the original, zoomed-
in,and non denoised signals.');

Comments: Tone removal was not able to be achieved after applying this technique of down
sampling. Maybe modifying the down-sampling values could help us remove the noise totally from
the signal. The tone gave a sinusoidal response.
NED University of Engineering & Technology
Department of _____________________ Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date
NED University of Engineering & Technology
Department of Electrical Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date
LAB SESSION 07

OBJECTIVE:
To study s-plane and plot impulse and frequency response for different pole zero location in s-
plane. Also to determine weather system is FIR or IIR.

THEORY:
The Laplace Transform of a general continuous time signal x (t) is defined as;
-st
X(S) = ∫ x(t) e dt.

Where the complex variable s=δ+ j w, with δ and w the real and imaginary parts. CTFT is a
subset of Laplace when δ =0. Since ‘δ’ information is not present in CTFT, therefore information
about stability can only be obtained from Laplace. If pole lies on L.H.S of s-plane, system is
stable. If pole lies on R.H.S of s-plane, system is unstable. If pole lies on y(jw)-axis, system is
marginally stable or oscillatory. If system has FIR, it is stable. If system is IIR, it can be stable or
unstable.

PROCEDURE:
Generate pole zero constellation in s plane.
1. Plot corresponding Frequency (Bode magnitude) response.
2. Plot impulse response and determine that the system is FIR or IIR.
3. Modify location of poles in s plane to observe the corresponding change in frequency and
impulse response.

STEPS.
1. Make a folder at desktop and name it as your current directory within MATLAB.
2. Open M-file editor and write the following code:

clear all;
close all;
clc;
Num = poly([(0-(i*(pi/2))),(0+(i*(pi/2)))]);
Zeros=roots(Num)
Den = poly([-1,-1]);
poles=roots(Den) sys=tf(Num,Den)

figure;
subplot(3,1,1);
pzmap(sys);
xlim([-2 2]);
ylim([-4 4]);
subplot(3,1,2);
[mag phase w]=bode(sys);
mag=squeeze(mag);
plot(w,mag);

subplot(3,1,3);
impulse(sys);
H=dfilt.df1(Num,Den);A=isfir(H)

3. Save the file as P091.m in your current directory and ‘run’ it.
RESULT:

1. Learn the specific logical bits of the code and make notes.
2. Observe the plots.
3. Now, explain (write) in your own words the cause and effects of what you just saw.

EXERCISE:

Change the location of poles from L.H.S of s-plane to y axis first, and then to R.H.S of s-
plane and observe the effects.
Tasks Lab Session 7
This lab session allows us discover the importance of s-plane to study the frequency response of a
system at a given input signals. In mathematics and engineering, the s-plane is the complex plane on
which Laplace transforms are graphed. It is a mathematical domain where, instead of viewing processes
in the time domain modeled with time-based functions, they are viewed as equations in the frequency
domain. It is used as a graphical analysis tool in engineering and physics.

Poles and Zeros of a transfer function are the frequencies for which the value of the denominator and
numerator of transfer function becomes infinite and zero respectively. The values of the poles and the
zeros of a system determine whether the system is stable, and how well the system performs.

The Objective of this lab session to study s-plane and plot impulse and frequency response for different
pole zero location in s-plane. Also to determine weather system is FIR (finite impulse response) or IIR
(infinite impulse response).

The lab code to observe the plots at different locations:


clear all; close all; clc; subplot(3,1,2)
Num = [1]; [H w]=freqs(Num,Den);
Den = poly([0]); % At origin mag=abs(H);
sys=tf(Num,Den) plot(w,mag)
zeros=roots(Num) xlabel('Frequency (\omega)')
poles=roots(Den) ylabel('Gain |H(\omega)|')
figure; title('Frequency Response')
subplot(3,1,1) axis tight
pzmap(sys) grid
xlim([-3 3]) subplot(3,1,3)
ylim([-3 3]) impulse(sys,'r')
grid

Task-1: Analysis of 1st order Analog system [one pole at origin]


a) Generate pole zero constellation of an analog system in s-plane having only one pole at s = 0

b) Write the transfer function of a system

c) Plot the corresponding frequency response and impulse response of a system. Also comment on the
stability of system.

𝟏
H (s) =
𝒔

Stability: marginally stable.


The impulse response of this system
neither dies out nor damages the
system
Task-2: Analysis of 1st order Analog system [one pole at LHP]
a) Generate pole zero constellation of an analog system in s-plane having only one pole at: s = -0.5

b) Write the transfer function of a system

c) Plot the corresponding frequency response and impulse response of a system. Also comment on the
stability of system.

𝟏
H (s) =
𝒔+𝟎.𝟓

Stability: Stable.
The Impulse response of the
system dies out so it is a totally
stable system.

Task-3: Analysis of 1st order Analog system [one pole at RHP]


a) Generate pole zero constellation of an analog system in s-plane having only one pole at: s=0.5

b) Write the transfer function of a system

c) Plot the corresponding frequency response and impulse response of a system. Also comment on the
stability of system.

𝟏
H (s) =
𝒔+𝟎.𝟓

Stability: Unstable
Changing the pole location to the
RHP caused an infinite impulse
response while the frequency
response is the same. The system’s
stability is defined from its
impulse response. We can also
observe that the pole location is
playing an important role here.
Task-4: Analysis of 2nd order Analog system [poles at jω axis]
a) Generate pole zero constellation of an analog system in s-plane having pure imaginary poles at:
s= jω =±j*pi/2

b) Write the transfer function of a system

c) Plot the corresponding frequency response and impulse response of a system. Also comment on the
stability of system.

𝟏
𝑯(𝒔) =
𝒔𝟐 + 𝟐. 𝟒𝟔𝟕
Stability: Marginally stable.

The frequency response of


this system is impulsive that
dictates the sinusoidal
nature of the impulse
response. So moving the
poles along imaginary axis is
basically manipulating the
sinusoids.

Task-5: Analysis of 2nd order Analog system [complex poles at LHP]:


a) Generate pole zero constellation of an analog system in s-plane having complex conjugate poles
at: s=σ+jω=-0.5±j*pi/2

b) Write the transfer function of a system

c) Plot the corresponding frequency response and impulse response of a system. Also comment on the
stability of system.

𝟏
𝑯(𝒔) =
𝒔𝟐 + 𝒔 + 𝟐. 𝟕𝟐
Stability: Stable.

Placing complex poles at LHP


causes an stable oscillating
decaying exponential impulse
response.
Task-6: Analysis of 2nd order Analog system [complex poles at RHP]
a) Generate pole zero constellation of an analog system in s-plane having complex conjugate poles at:
s=σ±jω=0.5±jpi/2

b) Write the transfer function of a system

c) Plot the corresponding frequency response and impulse response of a system. Also comment on the
stability of system.

𝟏
𝑯(𝒔) =
𝒔𝟐 − 𝒔 + 𝟐. 𝟕𝟐
Stability: Unstable.

Moving the poles to RHP


again causes an unstable
impulse response.

Task-7: Analysis of 2nd order Analog system [complex zeros and poles at LHP]
a) Generate pole zero constellation of an analog system in s-plane for given roots. S=j*pi/2,-j*pi/2
S=[-0.2+j*pi/4,-
b) Write the transfer function of a system 0.2-j*pi/4]

c) Plot the corresponding frequency response and impulse response of a system. Also comment on the
stability of system.

𝒔𝟐 + 𝟐. 𝟒𝟔𝟕
𝑯(𝑺) =
𝒔𝟐 + 𝟎. 𝟒𝒔 + 𝟎. 𝟔𝟓𝟕
Stability: Stable.

Placing zeros and poles near


to each other causes a
sudden rise and a fall in the
frequency response.
Task-8: Effect of system’s poles on system stability
Change the location of poles of a system defined in Task-7 from L.H.S of s-plane to axis first, and then to
R.H.S of s-plane and observe the effects on impulse response and frequency response of a system.

𝒔𝟐 + 𝟐. 𝟒𝟔𝟕
𝑯(𝑺) =
𝒔𝟐 − 𝟎. 𝟒𝒔 + 𝟎. 𝟔𝟓𝟕
Stability: Unstable.

Moving the poles to RHP


causes an unstable system at
again, the same frequency
response.

Task-9: Effect of system’s zeros on system stability


Modify the location of zeros of a system defined in Task-7 from to 𝑠 = ±(𝜋/2) to 𝑠 = -0.1 ± 𝑗(𝜋/2). Do
not change the location of poles. Does the impulse response change? Can we place analog system’s
zeros on the right-hand plane [RHP]?

𝒔𝟐 ± 𝟎. 𝟐𝒔 + 𝟐. 𝟒𝟕𝟕
𝑯(𝒔) =
𝒔𝟐 − 𝟎. 𝟒𝒔 + 𝟎. 𝟔𝟓𝟕
Stability (for zeros at RHP):
unstable.

Stability (for zeros at LHP):


stable.

Remember the system poles


remain at RHP, so the
response remains unstable for
either conditions.
LAB SESSION 08
OBJECTIVE:

To study z-plane and plot impulse and frequency response for different pole zero location in z-
plane.Also to determine weather system is FIR or IIR.

THEORY:

The z - Transform of a general discrete time signal x(n) is defined as;

X (z) = ∑∞
𝑛=𝑜 𝑥 (𝑛) z
-n

Where the complex variable z=r ∠w , with r the radius and w the angle. DTFT is a subset of z
transform when r =1. Since ‘r’ information is not present in DTFT, therefore information about
stability in discrete time can only be obtained from z transform. If pole lies inside the unit circle,
system is stable. If pole lies outside the unit circle, system is unstable. If pole lies at the unit circle,
system is marginally stable or oscillatory. If system has FIR, it is stable. If system is IIR, it can be
stable or unstable.

PROCEDURE:

1. Generate pole zero constellation in z plane.


2. Plot corresponding Frequency (Bode magnitude) response.
3. Plot impulse response and determine that the system is FIR or IIR.
4. Modify location of poles in z plane to observe the corresponding change in frequency and
impulse response.

STEPS:

1. Make a folder at desktop and name it as your current directory within MATLAB.
2. Open M-file editor and write the following code:

clear all;
close all;
clc;
Num = poly([(0-(i*(pi/2))),(0+(i*(pi/2)))]);

Den = poly([-1,-1]);
Num1 = poly([j,-j]);
Den1 = poly([exp(-1),exp(-1)]);
sys1=tf(Num1,Den1,1)
figure;
subplot(3,1,1);
pzmap(sys1);
xlim([-2 2]);
ylim([-4 4]);
subplot(3,1,2);
[mag phase w]=bode(sys1);

mag=squeeze(mag);
plot(w,mag);
xlim([0 100])
subplot(3,1,3);
impulse(sys1);
H=dfilt.df1(Num,Den);
A=isfir(H)
figure;
pzmap(sys1)
grid on;

3. Save the file as P010.m in your current directory and ‘run’ it.

RESULT:

1 Learn the specific logical bits of the code and make notes.
2 Observe the plots.
3 Now, explain (write) in your own words the cause and effects of what you just saw.

EXERCISE:

Change the location of poles from inside the unit circle to outside and at the unit circle and
observe and note the changes.
Tasks Lab Session 8

z-plane: A z-plane is a mathematical domain used in the analysis and design of discrete-time systems,
particularly in the field of digital signal processing. In the z-plane, complex numbers are represented by
z = σ + jω, where σ and ω are real numbers, and j is the imaginary unit.

The main difference between the s-plane and the z-plane lies in their application domains. The s-plane is
used for continuous-time systems in analog signal processing, while the z-plane is utilized for discrete-
time systems in digital signal processing.

The z-plane is crucial in digital signal processing as it allows for the representation and analysis of
discrete-time signals and systems. It plays a vital role in designing digital filters, control systems, and
various other applications.
clear all;close xlim([0 180]) mag=abs(H); subplot(3,1,3)
all;clc; grid plot((w*180)/pi, impulse(sys,'r')
Num = poly([0]); xlim([-3 3]), mag) grid
Den = ylim([-1.5 xlabel('\omega H=dfilt.df1(Num,
poly([0.9*exp(j*pi),0.9 1.5]) (in degrees)') Den);
*exp(-j*pi)]); subplot(3,1,2) ylabel('Gain A=isfir(H)
sys=tf(Num,Den,1) [H |H(\omega)|')
figure w]=freqz(Num,D title('Frequency
subplot(3,1,1) en); Response')
pzmap(sys)

Task-1: Analysis of 1st order Digital system [one pole inside the Unit circle at DC]
a) Generate pole zero constellation in z-plane for the following roots of a digital system:

b) Write the transfer function of a system [see command window]


[zero: = 0 & pole: = 0.9∠0]
c) Determine that whether the digital system is FIR or IIR

d) Plot corresponding frequency response and impulse response of a digital system.

( )=
− .
The system is IIR.
Task 2. Analysis of 1st order Digital system [pole inside the Unit circle at Fs/2]
a) Generate pole zero constellation in z-plane for the following roots of a digital system:
[zero: = 0 & pole: = 0.9∠ ± ]
b) Write the transfer function of a system
c) Determine that whether the digital system is FIR or IIR
d) Plot corresponding frequency response and impulse response of a digital system.
Imaginary Axis

( )=
+ . + .
The system is IIR
Gain |H( )|
Amplitude

Task 3. Analysis of 1st order Digital system [one pole at the DC location of Unit circle]
a) Generate pole zero constellation in z-plane for the following roots of a digital system:
[zero: = 0 & pole: = 1∠0]
b) Write the transfer function of a system
c) Determine that whether the digital system is FIR or IIR
d) Plot corresponding frequency response and impulse response of a digital system.

Pole-Zero Map
Imaginary Axis

0
( )=

-1

-3 -2 -1 0 1 2 3
The system is IIR.
Real Axis
Frequency Response
200
Gain |H( )|

100

0
0 20 40 60 80 100 120 140 160 180
(in degrees)

Impulse Response
2
Amplitude

0
0 2 4 6 8 10 12 14 16 18 20
Time (seconds)
Task4. Analysis of 1st order Digital system [pole at the Fs/2 location of Unit circle]
a) Generate pole zero constellation in z-plane for the following roots of a digital system:
b) Write the transfer function of a system. [zero: = 0 & pole: = 1∠ ± ]
c) Determine that whether the digital system is FIR or IIR
d) Plot corresponding frequency response and impulse response of digital system.
Imaginary Axis

( )=
+ +
The system is IIR.
Gain |H( )|
Amplitude

Task 5: Analysis of 1st order Digital system [one pole outside the Unit circle at DC]

a) Generate pole zero constellation in z-plane for the following roots of a digital system:
b) Write the transfer function of a system [zero: = 0 & pole: = 1.1∠0]
c) Determine that whether the digital system is FIR or IIR.
d) Plot corresponding frequency response and impulse response of a digital system.
Imaginary Axis

( )=
− .
The system is IIR
Gain |H( )|
Amplitude
Task 6. Analysis of 1st order Digital system [pole outside the Unit circle at Fs/2]
a) Generate pole zero constellation in z-plane for the following roots of a digital system:
b) Write the transfer function of a system. [zero: = 0 & pole: = 1.1∠ ± ]
c) Determine that whether the digital system is FIR or IIR
d) Plot corresponding frequency response and impulse response of a digital system.

( )=
+ . + .
The system is IIR.

Task 7: Analysis of 2nd order Digital system [poles at origin]

a) Generate pole zero constellation in z-plane for the following roots of a digital system:
b) Write the transfer function of a system [zeros: = 0.8944∠ ± 2 /3) & poles: = 0]
c) Determine that whether the digital system is FIR or IIR
d) Plot corresponding frequency response and impulse response of a digital system.
Pole-Zero Map
Imaginary Axis

0
+ . + .
-1 ( )=
-3 -2 -1 0 1 2 3
Real Axis The system is FIR.
Frequency Response
3
Gain |H( )|

0
0 20 40 60 80 100 120 140 160 180
(in degrees)

0.5

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Task 8: Analysis of 2nd order Digital system [complex poles inside the Unit circle].

a) Generate pole zero constellation in z-plane for the following roots of a digital system:
b) Write the transfer function of a system. [zeros: = 1∠ ± /2) & poles: = 0.8∠ ± /4]
c) Determine that whether the digital system is FIR or IIR
d) Plot corresponding frequency response and impulse response of a digital system.

+
( )=
− . + .
The system is IIR.

Task 9: Analysis of 2nd order Digital system [complex poles at the Unit circle]
a) Generate pole zero constellation in z-plane for the following roots of a digital system:
b) Write the transfer function of a system. [zeros: = 1∠ ± /2) & poles: = 1∠ ± /4]
c) Determine that whether the digital system is FIR or IIR
d) Plot corresponding frequency response and impulse response of a digital system.
Pole-Zero Map
Imaginary Axis

-1
²+
-3 -2 -1 0 1 2 3 ( )=
Real Axis ²+ . +
10 15 Frequency Response
15
The system is IIR
Gain |H( )|

10

0
0 20 40 60 80 100 120 140 160 180
(in degrees)

Impulse Response
5
Amplitude

-5
0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
Time (seconds)
Task 10: Analysis of 2nd order Digital system [complex poles outside the Unit circle]
a) Generate pole zero constellation in z-plane for the following roots of a digital system:
b) Write the transfer function of a system. [zeros: = 1∠ ± /2) & poles: = 1.2∠ ± /4]
c) Determine that whether the digital system is FIR or IIR
d) Plot corresponding frequency response and impulse response of a digital system.

²+
( )=
²− . + .
The system is IIR.

Task 11: Analysis of 2nd order Digital system [complex zeros inside the Unit circle]
a) Generate pole zero constellation in z-plane for the following roots of a digital system:
b) Write the transfer function of a system. [zeros: = 0.8∠ ± /2) & poles: = 0.8∠ ± /4]
c) Determine that whether the digital system is FIR or IIR
d) Plot corresponding frequency response and impulse response of a digital system.

+ .
( )=
− . + .
The system is IIR
Task 12: Analysis of 2nd order Digital system [complex zeros outside the Unit circle]
a) Generate pole zero constellation in z-plane for the following roots of a digital system:
b) Write the transfer function of a system. [zeros: = 1.2∠ ± /2) & poles: = 0.8∠ ± /4]
c) Determine that whether the digital system is FIR or IIR
d) Plot corresponding frequency response and impulse response of a digital system

+ .
( )=
− . + .
The system is IIR.

General Discussion for Predicting the response of the system:


We can analyze the pole-zero plot in the z-plane to determine whether a system is an Infinite
Impulse Response (IIR) or Finite Impulse Response (FIR) filter.
Infinite Impulse Response (IIR) Filters:
 IIR filters have poles that may be located anywhere in the z-plane.
 Presence of poles outside the unit circle (poles with magnitude greater than 1) is a
characteristic feature of IIR filters.
 IIR filters can have both finite and infinite-duration responses.
Finite Impulse Response (FIR) Filters:
 FIR filters have all their poles located at the origin (z = 0).
 FIR filters have zeros that can be located anywhere in the z-plane, but they must not be
outside the unit circle (zeros with magnitude greater than 1).
 FIR filters are always stable and have a finite-duration response.
In summary, if you observe poles outside the unit circle in the z-plane, it indicates an IIR filter. If
all the poles are at the origin (z = 0) and there are no poles outside the unit circle, it suggests an
FIR filter.
LAB SESSION 09
OBJECTIVE:
Object of this lab is introduction to digital filters and its types, design FIR filter and study how it
performs filtering on a signal. Further truncate different types of FIR filter like Low Pass, High
Pass, Band Pass using different windows like rectangular, Kaiser Etc. and compare the results
obtained from different windows.

THEORY:
The process of deriving a realizable transfer function of a digital filter by considering given
frequency response specifications is known as digital filter design. The digital filter can be
classified as:

1. Finite –duration impulse response (FIR) filter


2. Infinite –duration impulse response (IIR) filter
In MATLAB, there are built in functions which can be used to design digital filter like IIR and
FIR.

The different types of FIR filters are listed as follows:

• Window techniques based FIR filter.


1. Rectangular windows.
2. Hamming window.
3. Hanning window.
4. Blackman window.
5. Barlett window.
6. Kaiser window.
• Equiripple linear phase FIR filter.
• Least square error FIR filters.

The different types of IIR filters are listed as follows:

• Butterworth filter
• Chebyshev Type I filter
• Chebyshev Type II filter
• Elliptic filter

FIR digital filter operates on digital sample values. It uses current and past input samples to
produce a current output sample. It does not use previous output samples. There are various
types of FIR filter based on need viz. low pass, high pass, band pass and band stop, Low pass
filter.

Following points are usually considered to design FIR filter other the window type.
INPUT:
• Window Type
• Passband and stopband ripples
• passband and stopband edge frequencies
• sampling frequency
• order of the filter
• window coefficients

OUTPUT:
• magnitude and phase responses

COMPARISON OF FIR AND IIR FILTERS


1. FIR filters are Finite Impulse Response filters with no feedback, whereas IIR contains
feedback.
2. Transfer function of FIR filter does not contain any non-trivial poles. Their frequency
response is solely dependent on zero locations. IIR filters contain poles as well as zeros.
3. As there are no poles, FIR filters cannot become unstable; however, IIR filters can
become unstable if any pole lies outside the unit circle in z-plane.
4. More number of coefficients is needed to design the desired filter in FIR than IIR.

PROCEDURE:
TASK-1

1. Create a signal vector containing two frequencies as:


i) 100 Hz. and ii) 150 Hz. with Fs = 1000 Hz.
2. Design two band pass FIR filters with 64 coefficients and with pass bands as i) 125 to
175 Hz. and ii) 75 to 125 Hz.
3. Use both filters on the created signal and observe their outputs.
4. Plot frequency responses and pole-zero constellations of both filters and note
observations.

close all; clear all; clc; % Frequencies in Hz.

F1 = 100; F2 = 150;

% Sampling Frequency in samples/sec.


Fs = 1000;

t = [0 : 1/Fs : 1]; % Time Vector


F = Fs*[0:length(t)-1]/length(t); % Frequency Vector

x = exp(j*2*pi*F1*t)+2*exp(j*2*pi*F2*t); % Signal Vector

bh = fir1( 64 , [125 175]/500); % filter coeffs.


bl = fir1( 64 , [75 125]/500); % filter coeffs.
[hh,wh]=freqz(bh,1,length(t),'whole'); % Frequency
response for filter 1
[hl,wl]=freqz(bl,1,length(t),'whole'); % Frequency
response for filter 2
% Filter operation - see filtfilt in help to learn what it
does

yh = filtfilt(bh,1,x);
yl = filtfilt(bl,1,x);

% Plotting

figure, subplot(5,1,1),

plot(F,abs(fft(x)));

xlim([0 Fs/2]);
title('FFT of original signal');

subplot(5,1,2),
plot(F,abs(hh));
xlim([0 Fs/2]);
title('Frequency response of Filter One');

subplot(5,1,3),
plot(F,abs(fft(yh)));
xlim([0 Fs/2]);
title('FFT of filtered signal from filter one');

subplot(5,1,4),
plot(F,abs(hl));
xlim([0 Fs/2]);
title('Frequency response of Filter Two');

subplot(5,1,5),
plot(F,abs(fft(yl)));
xlim([0 Fs/2]);
title('FFT of filtered signal from filter two');
xlabel('Hz.')
% Pole Zero Constellations

[bh,ah] = eqtflength(bh,1);
[zh,ph,kh] = tf2zp(bh,ah);
[bl,al] = eqtflength(bl,1);
[zl,pl,kl] = tf2zp(bl,al);

figure,
subplot(1,2,1),
pzplane(bh,ah);
xlim([-1.5 1.5]);
ylim([-1.5 1.5]);
title('Filter_One');
subplot(1,2,2),
pzplane(bl,al);
xlim([-1.5 1.5]);
ylim([-1.5 1.5]);
title('Filter Two');

TASK -2
Write a program to design a FIR filter using Hanning windows,take inputs from user for design
values of filter.

close all;
clear all;
clc;

fp=input('Enter the pass band frequency');


fs=input('Enter the stop band frequency');
rp=input(' Enter the pass band attenuation');
rs=input('Enter the stop band attenuation');
f=input(' Enter the sampling frequency');

% Calculating filter order

num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n=abs(n);

% Normalizing the frequencies

wp=2*fp/f;
ws=2*fs/f;
wn=(ws+wp)/2;
%Adjusting the filter order. The order of window must be an odd
number
%and the order of filter must be one less than that of the
window

if (rem(n,2)==0)
m=n+1;
else
m=n;
n=n-1;
end

%Window sequence calculation

w=hann(m);

%Calculation of filter coefficients

b=fir1(n,wn,'low',w);

%Plotting the filter response

freqz(b,1,500,3000);
TITLE('Magnitude and Phase response');

TASK-3
Write a program for FIR(Finite Impulse Response) filter like Low pass FIR filter, High pass FIR
filter, Band pass FIR filter and Band stop FIR filter using Rectangular window using MATLAB .

ALGORITHM:
LOW PASS FILTER:
Step 1: Read the input sequence
Step 2: Perform low pass filter calculations
Step 3: Plot the output sequences

HIGH PASS FILTER:


Step 1: Read the input sequence
Step 2: Perform high pass filter calculations
Step 3: Plot the output sequences

BAND PASS FILTER:


Step 1: Read the input sequence
Step 2: Perform band pass filter calculations
Step 3: Plot the output sequences

BAND STOP FILTER:


Step 1: Read the input sequence
Step 2: Perform band stop filter calculations
Step 3: Plot the output sequences

PROGRAM:
clc;
clear all;
close all;
rp=input('Enter the passband ripple(rp):');
rs=input('Enter the stopband ripple(rs):');
fp=input('Enter the passband frequency(fp):');
fs=input('Enter the stopband frequency(fs):');
f=input('Enter the sampling frequency(f):');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
y=boxcar(n1);
%Low pass filter
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(m);
ylabel('Gain(db)->');
xlabel('(a)Normalised frequency->');
%High pass filter
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));

subplot(2,2,2);
plot(m);
ylabel('Gain(db)');
xlabel('(b)Normalised frequency');
%Band pass filter
wn=[wp*ws];
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,3);
plot(m);
ylabel('Gain(db)');
xlabel('(c)Normalised frequency');
%Band stop filter==============
wn=[wp*ws];
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);
plot(m);
ylabel('Gain(db)');
xlabel('(d)Normalised frequency-');

EXERCISE:
Q1. Perform Q3.using Hamming and Kaiser Window.
Compare results of designed filters using three different windows on a single plot.
Tasks Lab Session 9

Discussion:
Digital filters are algorithms used to modify or extract information from digital signals. Types include
Finite Impulse Response (FIR) with fixed-length response, and Infinite Impulse Response (IIR) with
feedback. FIR provides linear phase response, while IIR offers efficiency in terms of computation. Filters
are crucial in signal processing for tasks like noise reduction and signal enhancement. In MATLAB, you
can implement digital filters using functions like 'fir1' for FIR and 'butter' for IIR, specifying filter
parameters and applying them to signals using 'filter' function.

In MATLAB, windowing involves multiplying a signal by a window function to minimize spectral leakage
and artifacts during signal analysis. Common window functions include 'hamming,' 'hann,' 'blackman,'
and 'rectangular.' Use the 'window' function to generate a window of specified length, and apply it to
the signal using element-wise multiplication for improved accuracy in signal processing applications.

Lab Work:
clear all; close all; subplot(411); subplot(413)
clc; plot(n*Ts,x1,'r') plot(n*Ts,x2,'r')
F1 = 500; F2 = 600; hold hold
Fs = 8000; stem(n*Ts,x1,'filled') stem(n*Ts,x2,'filled')
Ts = 1/Fs; xlabel('Time (sec)'); xlabel('Time (sec)')
N = 64; n =[0:N-1]; ylabel('Amplitude') ylabel('Amplitude')
k = n; Df = Fs/N; Fk = title('Signal'); grid; title('Signal')
k.*Df; axis tight grid
axis tight
x1 = sin(2*pi*F1*n*Ts); subplot(412)
X1 = abs(fft(x1,N)); stem(Fk,X1,'r','filled') subplot(414)
x2 = sin(2*pi*F2*n*Ts); xlabel('Frequency (Hz)') stem(Fk,X2,'r','filled')
X2 = abs(fft(x2,N)); ylabel('DFT Magnitude') xlabel('Frequency (Hz)')
title('Spectrum') ylabel('DFT Magnitude')
xlim([0 Fs]) title('Spectrum')
grid xlim([0 Fs])
grid

Two sinusoids of frequencies 500 Hz


and 600Hz are plotted and their DFTs
were calculated through the fft()
command. The magnitude of DFT is
also plotted to view the frequency
components present in the respective
signals.
clear all; subplot(321) subplot(323) subplot(325)
close all; plot(n*Ts,x,'r' stem(n,w,'r','filled') plot(n*Ts,xw,'r'
clc; ) xlabel('Samples') )
hold ylabel('Amplitude') hold
F = 1050; stem(n*Ts,x,'fi title('Window stem(n*Ts,xw,'fi
Fs = 8000; lled') Function') lled')
Ts = 1/Fs; xlabel('Time grid xlabel('Time
N = 64; (sec)') axis tight (sec)')
n = [0:N-1]; ylabel('Amplitu ylabel('Amplitud
k = n; de') subplot(324) e')
Df = Fs/N; title('Signal') stem(abs(fft(w)),'r',' title('Windowed
Fk = k.*Df; grid filled') Signal')
xlabel('Samples') grid
x = subplot(322) ylabel('Magnitude') axis tight
sin(2*pi*F*n*Ts+ stem(Fk,X,'fill title('Spectrum of
pi/4); ed') Window Function') subplot(326)
xlabel('Frequen grid stem(Fk,Xw,'fill
w = cy (Hz)') axis tight ed')
window(@hanning, ylabel('DFT xlabel('Frequenc
N); Magnitude') y (Hz)')
xw = x.*w'; % title('Spectrum ylabel('Windowed
Windowed signal ') DFT Magnitude')
X = grid title('Windowed
abs(fft(x)); Spectrum')
Xw = grid
abs(fft(xw));

CONCLUSION: A signal of
1050Hz was discretized and
its spectrum was plotted. A
leakage was observed in
the spectrum. A window
function was applied
known as “hanning” to
minimize the spectral
Leakage as discussed
earlier. The leakage is
successfully minimized as
can be seen in the
windowed spectrum.
LAB TASKS
1. Condition of DFT/FFT Leakage
Fill the following table specifying whether DFT leakage would happen or not?
S.No Fs N Input contains these DFT Leakage
[samples/sec] [samples] frequencies in Hz Yes or No?

1 8000 8 1000 NO
2 8000 9 1000, 2000 YES
3 16000 32 250, 500, 1000, 2250 NO
4 22050 128 11025 NO
5 44100 4096 1000, 2000, 2500, 11025 YES
6 44100 44100 1101, 2202, 3303 NO
7 96000 48000 1200, 1202, 2002, 2003 YES
Conclusion: DFT leakage occurs when the input signal frequency is not an exact integer
multiple of the sampling frequency, resulting in spectral spreading and distortion in the
frequency domain representation. To determine the likelihood of DFT leakage:
1. Sampling Frequency (Fs): Ensure that the sampling frequency is sufficiently high
to accurately capture the input signal frequencies.
2. Input Signal Frequencies: If the input signal frequencies are integer multiples of
the fundamental frequency (Fs/N), where N is the number of samples, leakage is
less likely. Non-integer relationships may cause leakage.
3. Number of Samples (N): Choose an appropriate number of samples to capture the
signal adequately. More samples generally improve frequency resolution and reduce
leakage.
If the input frequencies do not align well with the sampling frequency and number of
samples, leakage is more probable. Applying window functions before the DFT can mitigate
leakage but at the cost of frequency resolution.

Task-2: Calculation of cycles in N sample interval (length of DFT/FFT)


Calculate exactly how many cycles of the 440 Hz wave sampled at 1000 Hz are contained in
the 1024-sample window. Explain why this number indicates leads to spectral leakage.

F = 440Hz, Fs = 1000Hz, N = 1024 samples.


𝐹 440
𝑁𝑜. 𝑜𝑓 𝑐𝑦𝑐𝑙𝑒𝑠 = 𝐹𝑠 ∗ 𝑁 = 1000 ∗ 1024 = 450.56 cycles.
The number of cycles is not an integer multiple of the input frequency therefore spectral
leakage occurs.

Task-3: DFT or FFT Leakage


a) Generate two sinusoids of frequencies 500 Hz and 600 Hz. Both signals should be
sampled at 8000 samples/sec.
b) Take 64-point DFT of both signals and observe their spectrums.
c) Comment on the DFT Leakage for both cases.
The Code for this task is the same as written in the very first page.

There is no DFT leakage


observed in the 500Hz as
the sampling frequency
8000Hz is the integral
multiple of 500Hz

DFT leakage occurring in


600 Hz signal since the
sampling frequency and
input frequency do not
align.

Task-4: Evaluation of Various Window functions using wintool of MATLAB or


Window Analysis &; Designing
Type wintool (Window Design &amp; Analysis Tool) in the command window of MATLAB.
Observe different window functions like Rectangular (no window), Triangular, Hamming,
Hanning, Blackman, Flat Top, Gaussian etc. Attach the time domain and frequency domain
representations of various window functions and make a comparison between their
performances on the basis of following attributes:
a) Leakage Factor in %
b) Width of the main lobe in fraction of π () or
c) The first (highest) side lobe magnitude in dB
d) The rate of side lobes falloff in dB/octave.
1. Rectangular
2. Triangular

3. Hamming

4. Hann
5. Gaussian

First Side
Window Leakage Main Lobe Rate of side
S.no. Lobe
name Factor Width lobes falloff
Magnitude
1 Rectangular 9.14% 0.027344 -22.86713 -13.3
2 Triangular 0.28% 0.039063 -3.546566 -26.6
3 Hamming 0.03% 0.039063 -16.34576 -42.5
4 Hann 0.05% 0.042969 -1.529982 -31.5
5 Gaussian 0.01% 0.042969 -1.56708 -44

Task-5: Spectrum of Windowed signal


a)Generate a sinusoid of frequency 1050 Hz sampled at 8000 samples/sec. Initial phase is pi/4.
b) Take 64-point DFT of the generated signal and observe the spectrum.
c) Comment on the DFT Leakage phenomenon for the above case.
d) Generate a triangular window function of 64 points.
e) Now apply a triangular window to the signal and then observe the spectrum of windowed signal.
f) Change the window function from Triangular to Hamming, Hanning, Blackman, Flat Top and
Gaussian. Compare the results of these window functions on a signal’s spectrum.

The code for this task is same as written on page 2.


The sinusoid of frequency 1050Hz sampled at 8000 samples/sec having an initial phase pi/4 is
plotted. 64 point DFT was applied. As a result spectrum was seen having a leakage in it. Therefore
the objective of this task is to minimize the leakage through different window functions in the
matlab. Applying different window functions:
Triagular window:

Hamming window:
Hanning window:

Blackman window:
Flat Top window:

Gaussian Window:

Conclusion: Various window functions were applied to the spectrum of given spectrum to
minimize leakages. Gaussian window has the minimum leakage factor for the given signal.
Remember the leakage factor of windows can vary with respect to the shape of given signal.
NED University of Engineering & Technology
Department of _____________________ Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date
NED University of Engineering & Technology
Department of Electrical Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date
LAB SESSION 10
OBJECTIVE:
Object of this lab is to design different IIR filter using FDA tool.

THEORY:
Filter Design and Analysis Tool (FDA Tool) is Graphic User Interface for designing and analyzing
filters. It is used to design FIR and IIR filters by entering the desired filter specifications, or by
importing filter from MATLAB workspace or by adding, moving or deleting poles and zeros. After
designing a filter, the response can be viewed and analyses in other Graphic User Interface tool
named Filter Visualization Tool (FV Tool) linked with FDA Tool. The different types of responses
that can be viewed are listed below:

• Magnitude response
• Phase response
• Group delay
• Phase delay
• Impulse response
• Step response
• Pole-zero plot
• Zero-phase plot
OPENING FDA TOOL WINDOW:
FDA Tool can be opened using command:
fdatool

Figure A
The different steps involved in designing a filter using FDA Tool can be listed as:

1. Selection of type of response required


2. Selection of type of filter design
3. Specifying the filter order
4. Entering the filter specifications
5. Entering the magnitude specifications

After providing the information listed above, filter can be designed and its response can be
viewed and analysed.

The complete description of the FDA Tool window and different steps required to design a filter
are elaborated below:
1. Selecting response type: The desired response type is selected from the list of available
options, i.e., lowpass, highpass, bandpass, bandstop, differentiation, multiband, peaking etc.
2. Type of design method: The design can be of FIR or IIR filter. Depending upon whether
FIR Or IIR filter design is selected, further options are available in the dropdown menu.
In IIR filter design, the different options available in dropdown menu are as given below:

• Butterworth
• Chebyshev type I
• Chebyshev type II
• Elliptic
• Maximally flat
• Least Pth-norm
• Const least Pth-norm
In FIR filter design the options available are listed as follows:
• Equirriple
• Least square
• Window
• Const least squares
• Complex equiripple
• Least Pth norm
• Constrained equiripple
• Generalized equiripple
• Constrained band equirriple
• Interpolated FIR

The options available depend upon the selection of response type.

3. Filter order: Under this, two options available are as


• User-defined order: Under this option user has to enter the order of the filter.
• Minimum order: The other option available for selecting the filter order is
minimum order. It is calculated by system itself.

4. Filter specifications: Depending upon the response type and design method selected,
the graphical representation of generalized filter specifications appear in the display
region of FDA Tool. These specifications are ‘Frequency Specifications’ and
‘Magnitude Specification’.
These specifications are provided by the user, as per filter design requirement, in the
appropriate blocks.

5. Designing filter: After all the requisite information is entered, a filter can be designed by
clicking the ‘Design Filter’ button available at the bottom of the window. Filter |
coefficients are calculated and magnitude response appears in the display region.
(Note: ‘Design Filter’ button will be disabled once the filter coefficients are computed. This
button will be enabled again in case any changes are made in the filter specifications.)

6. Displaying filter responses: Once the filter coefficients are calcu

lated as per the specifications provided by the user, the display region will show
magnitude response of the designed filter. The other filter response characteristics
can be viewed in the display region or FV Tool. The response to be viewed can be
selected from the different icons displayed on the toolbar shown in Figure below.

Figure : Different Response Icons on the Toolbar

(NOTE: The different responses for display can also be selected from the
‘Analysis’ menu on menu bar.)

7. Current filter information: The information about the designed filter is given in
the ‘Current Filter Information’ region of FDA Tool window as shown
in Figure A The information provided is about the ‘structure’, ‘order’, ‘stability’ and
‘source’
• Storing a filter
The designed filter is stored by clicking ‘Store Filter’ button in the
‘Current Filter Information’ region.
• Filter manager
The ‘Filter Manager’ button opens up a new Filter Manager window
(Figure B) showing the list of filters stored. This window also has
options as: Edit current filter, Cascade, Rename, Remove and FV Tool.

Figure B Filter Manager Window


To cascade two or more filters, highlight the designed filters and press ‘Cascade’ button.
A new cascaded filter is added to the ‘Filter Manager’.

8. Saving and opening filter design session:


The filter design session is saved as MAT-file and can be used later on. It can be saved by
clicking save icon or selecting save session
option in File menu and giving desired session name. Similarly, the saved session
can be opened by clicking open icon or by selecting open option in file menu and
selecting the previously saved filter design session.

FILTER VISUALIZATION TOOL:

The response characteristics can be viewed in a separate window by selecting the ‘Filter
Visualization Tool’ (FV Tool) from ‘view’ menu or clicking the ‘Full View Analysis’ button
on the toolbar. The FV Tool window is shown in Figure C

FV Tool has most of the menus on the menu bar and icons on the toolbar similar to that FDA
Tool with some additional icons which are mainly used to work with representation of the
responses.

Figure C Filter Visualization Tool(FV Tool) window


IIR FILTER DESIGN USING FDA TOOL
TASK-1
Design an IIR Butterworth band pass filter with the following
specifications:
Normalized pass band edges at 0.40 and 0.65
Normalized stop band edges at 0.3 and 0.75
Pass band ripple 1 dB
Minimum stop band attenuation 40 dB
Show (i) Magnitude response (ii) Phase response (iii) Group delay (iv) Phase delay response.
Solution:
As per the given specifications, the requisite data is entered in new FDA Tool window
as shown in Figure

Figure. FDA Tool Window Showing Specification Entered and Magnitude Response for Task-1.

The filter is designed for minimum order so as to reduce the complexity of the design.
In case, it has to be designed for user defined order, then the order of the filter has to be
calculated first by user using appropriate formulas or MATLAB function.
The other responses can be viewed by clicking on the appropriate icon on the toolbar and
responses obtained are shown in Figures below
Figure Magnitude Response in dB

Figure Phase Response


Figure Group Delay Response

Figure. Phase Delay

These responses can also be viewed in FV Tool.


TASK-2

Design a Type II Chebyshev IIR lowpass filter with the following specifications:
Passband frequency 1,200 Hz

Stopband frequency 1,700 Hz

Sampling frequency 6,000 Hz

Passband ripple 0.50 dB

1. Show magnitude response.


2. Show pole/zero plot.

Solution: FDA Tool Window showing given specifications duly entered and magnitude
response in response display region is shown in Figure.

Figure. FDA Tool Window for Example


By using the FV Tool, the magnitude response and pole/zero plot is obtained as separate figures and is
shown in Figures.

Figure. Magnitude Response for Task-2.

Figure Pole/zero Plot for Q2


TASK-3:
Design an elliptic IIR low pass filter with following specifications:

Pass band ripple 0.5 dB

Stop band attenuation 40 dB

Pass band frequency 800 Hz

Stop band frequency 1,000 Hz

Sampling frequency 4,000 Hz

1. Show magnitude and phase response in the same window.


2. Obtain filter information.
Solution:
As per given specifications, the requisite data is entered in FDA Tool window. By clicking
appropriate icon on toolbar, the magnitude and phase responses are obtained in the same
window.
1. These magnitude and phase responses obtained are viewed in FV Tool window also and
are shown in Figure .
Figure . Magnitude and Phase Response for Task-3.

2. To obtain the information about the filter ‘Filter Information’ icon on Toolbar of FDA
Tool Window is clicked or ‘Filter Information’ option is selected from ‘Analysis’ menu. The
detailed filter information appears in the display region as shown in Figure a, b and c.
Figure ‘Filter information’ for Task-2
The filter information is obtained by scrolling down the text in the window shown
in Figure 15.41b.

EXERCISE:

Record Your Voice at home while turn any motor of your house ON.
Design a filter using FDA Tool.

Remove sound of motor from recorded signal.

Listen the output signal.


Tasks Lab Session 10
Task-1: Designing of an IIR Butterworth filter
Design a 16 th order IIR Butterworth bandpass filter with the following specifications:
a) Normalized pass band edges at 0.40 and 0.65
b) Normalized stop band edges at 0.3 and 0.75 clear all, close all, clc;
% Filter specifications
c) Pass band ripple 1 dB Rp = 1; % Pass band ripple
in dB
d) Minimum stop band attenuation 40 dB Rs = 40; % Stop band
attenuation in dB
Attach (i) Magnitude response (ii) Phase response Fp1 = 0.40; % Normalized pass
band edge 1
iii) Impulse Response (iv) Pole Zero plot. Fp2 = 0.65; % Normalized pass
band edge 2
Fs1 = 0.3; % Normalized stop
band edge 1
Fs2 = 0.75; % Normalized stop
band edge 2

% Filter order
n = 16;

% Butterworth filter design


[z, p, k] = butter(n, [Fp1 Fp2],
'bandpass');
[b, a] = zp2tf(z, p, k);

% Frequency response
[H, Freq] = freqz(b, a, 1024);

% Magnitude response plot


figure;
subplot(2,2,1);
plot(Freq/pi, 20*log10(abs(H)),
'g','linewidth',1.5);
title('Magnitude Response');
xlabel('Normalized Frequency (\pi
radians/sample)');
Comments: The MATLAB code successfully designs a 16th
ylabel('Magnitude (dB)');
order IIR Butterworth bandpass filter meeting specified
criteria required in the task. The resulting plots depict the % Phase response plot
filter's magnitude and phase responses, impulse response, subplot(2,2,2);
and pole-zero distribution. The design aligns with the plot(Freq/pi,
angle(H),'k','linewidth',1.5);
desired specifications, showcasing the effectiveness of the title('Phase Response');
Butterworth filter in achieving a narrow band-pass xlabel('Normalized Frequency (\pi
response with a smooth frequency transition. Users can radians/sample)');
ylabel('Phase (radians)');
easily customize the filter order for further optimization.
% Impulse response
subplot(2,2,3);
impz(b, a);
title('Impulse Response');
xlabel('Time');
Task-2: Designing of an IIR Chebyshev Type II filter
Design a Type II Chebyshev IIR lowpass filter with the following specifications:
Passband frequency 1,200 Hz
Stopband frequency 1,700 Hz % Filter specifications
Sampling frequency 6,000 Hz Fp = 1200; % Passband frequency
Passband ripple 0.50 dB in Hz
Fs = 1700; % Stopband frequency
Attach (i) Magnitude response (ii) Phase response
in Hz
(iii) Impulse Response (iv) Pole Zero plot Fsampling = 6000; % Sampling frequency
in Hz
Rp = 0.5; % Passband ripple in
dB

% Normalized frequencies
Wp = Fp / (Fsampling / 2);
Ws = Fs / (Fsampling / 2);

% Chebyshev Type II filter design


[n, Wn] = cheb2ord(Wp, Ws, Rp, 60); %
60 dB stopband attenuation
[b, a] = cheby2(n, 60, Wn);

% Frequency response
[H, Freq] = freqz(b, a, 1024);

% Magnitude response plot


figure;
subplot(2,2,1);
plot(Freq, 20*log10(abs(H)),'g');
title('Magnitude Response');
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
Comments: % Phase response plot
subplot(2,2,2);
This MATLAB code designs a Type II Chebyshev IIR plot(Freq, angle(H),'g');
lowpass filter with specified passband and stopband title('Phase Response');
frequencies, sampling frequency, and passband xlabel('Frequency (Hz)');
ylabel('Phase (radians)');
ripple. The resulting plots include the magnitude and
phase responses, impulse response, and a pole-zero % Impulse response
plot. The filter exhibits the desired characteristics, subplot(2,2,3);
impz(b, a);
and users can adjust parameters for further title('Impulse Response');
customization. The code facilitates a comprehensive xlabel('Time');
ylabel('Amplitude');
understanding and implementation of the designed
Chebyshev Type II filter. % Pole-Zero plot
subplot(2,2,4);
zplane(b, a);
title('Pole-Zero Plot');
Task-3: Designing of an IIR Elliptic Filter
Pass band ripple 0.5 dB, Stop band attenuation 40 dB, Pass band frequency 800 Hz
Stop band frequency 1,000 Hz, Sampling frequency 4,000 Hz
close all, clear all, clc;
a) Show magnitude and phase response in the same window. % Filter specifications
b) Attach impulse response Rp = 0.5; % Passband ripple in
c) Attach pole zero plot dB
d) Obtain filter information. Rs = 40; % Stopband
attenuation in dB
Fp = 800; % Passband frequency
in Hz
Fs = 1000; % Stopband frequency
in Hz
Fsampling = 4000; % Sampling
frequency in Hz

% Normalized frequencies
Wp = Fp / (Fsampling / 2);
Ws = Fs / (Fsampling / 2);

% Elliptic filter design


[n, Wn] = ellipord(Wp, Ws, Rp, Rs);
[b, a] = ellip(n, Rp, Rs, Wn);

% Frequency response
[H, Freq] = freqz(b, a, 1024);

% Magnitude and phase response plot


figure;
subplot(2,2,1);
plot(Freq,
20*log10(abs(H)),'k','linewidth',1.5)
;
Comments: title('Magnitude Response');
xlabel('Frequency (Hz)');
This MATLAB code designs an IIR elliptic filter based on the ylabel('Magnitude (dB)');
specified pass-band ripple, stop-band attenuation, pass-band
subplot(2,2,2);
frequency, stop-band frequency, and sampling frequency. The
plot(Freq,
magnitude and phase responses are plotted in the same angle(H),'k','linewidth',1.5);
window, while the impulse response and pole-zero plot are title('Phase Response');
presented separately. Additionally, filter information is xlabel('Frequency (Hz)');
ylabel('Phase (radians)');
displayed, providing details on the filter's order, numerator, and
denominator coefficients. Users can easily customize the code % Impulse response
for specific requirements and gain insights into the designed subplot(2,2,3);
elliptic filter. impz(b, a);
title('Impulse Response');
xlabel('Time');
ylabel('Amplitude');

% Pole-Zero plot
subplot(2,2,4);
zplane(b, a);
title('Pole-Zero Plot');
Task-4: IIR filter designing by Pole-Zero placement method
Design a filter with pass bands at 5000, 8000 and 15000 Hz and stop bands at 0 Hz and 11025.
The sampling rate is 44,100 Hz.
a) Attach pole zero plot
b) Attach magnitude response
c) Attach phase response
d) Attach impulse response
e) Attach filter coefficients
f) Write the difference equation
g) Listen to the filtered output and explain what you heard?

% Given specifications
passbands = [5000, 8000, 15000];
stopbands = [0, 11025];
sampling_rate = 44100;

% Step 1: Determine Filter Order


(Example: 4th order)
order = 4;

% Step 2: Choose Pole and Zero


Locations
zeros = 2 * pi * passbands /
sampling_rate;
poles = 2 * pi * stopbands /
sampling_rate;

% Step 3: Compute Transfer


Function
[numerator, denominator] =
zp2tf(zeros.', poles.', 1);

% Create a new figure


figure;

% Step 4: Plot Pole-Zero Diagram


subplot(2, 2, 1);
zplane(numerator, denominator);
title('Pole-Zero Plot');

% Step 5: Frequency Response


subplot(2, 2, 2);
freqz(numerator,
denominator, linspace(0,
sampling_rate/2, 1000),
sampling_rate);
title('Frequency Response');

% Step 6: Impulse Response


subplot(2, 2, 3);
impz(numerator, denominator);
title('Impulse Response');

% Step 7: Filter Coefficients


subplot(2, 2, 4);
stem(0:length(numerator)-1, numerator, 'b', 'LineWidth', 2, 'Marker', 'o');
hold on;
stem(1:length(denominator)-1, denominator(2:end), 'r', 'LineWidth', 2,
'Marker', 'x');
title('Filter Coefficients');
legend('Numerator', 'Denominator');
xlabel('Coefficient Index');
ylabel('Coefficient Value');
grid on;
hold off;

% Step 8: Difference Equation


disp('Difference Equation:');
disp(['y[n] = ' num2str(numerator(1)) 'x[n] + ' num2str(numerator(2)) 'x[n-1]
+ ... - ' num2str(denominator(2)) 'y[n-1] - ' num2str(denominator(3)) 'y[n-2]
- ...']);

% Step 9: Filtered Output


% (Apply the filter to a test signal)

% Step 10: Listen and Analyze

% (Listen to the filtered output and compare to the original signal)

Discussion:
The code generates a white noise input signal and filters it using the designed IIR filter. Listening to
the output signal, you may observe that the filter passes the frequencies in the specified passbands
(5000 Hz, 8000 Hz, and 15000 Hz) while attenuating frequencies in the stopbands (0 Hz and 11025
Hz). The sound should exhibit a tonal quality due to the filtered frequencies within the passbands.
Adjust filter parameters as needed for different characteristics.
Task-5: IIR filter designing by Pole-Zero placement method

Design an IIR filter with the following specifications:


Pass band at pi/2 and stop bands at 0 and pi. Take .
a) Attach pole zero plot
b) Attach magnitude response
c) Attach phase response
d) Attach impulse response
e) Attach filter coefficients
f) Write the difference equation
g) Listen to the filtered output and explain what you heard?

clc, clear all, close all;


% Given specifications
passband_freq = pi/2;
stopband_freq = [0, pi];
sampling_rate = 2*pi; % Nyquist frequency

% Step 1: Determine Filter Order


(Example: 2nd order)
order = 2;

% Step 2: Choose Pole and Zero


Locations
zeros = [];
poles = -exp(1i *
[passband_freq,
conj(passband_freq)]);

% Step 3: Compute Transfer


Function
[numerator, denominator] =
zp2tf(zeros.', poles.', 1);

% Create a new figure


figure;

% Step 4: Plot Pole-Zero Diagram


subplot(2, 2, 1);
zplane(numerator, denominator);
title('Pole-Zero Plot');

% Step 5: Frequency Response


subplot(2, 2, 2);
freq_vector = linspace(0, sampling_rate/2, 1000);
[h, w] = freqz(numerator, denominator, freq_vector, sampling_rate);
plot(w, abs(h));
hold on;
plot(w, angle(h));
title('Frequency Response');
xlabel('Frequency (rad/sample)');
ylabel('Magnitude and Phase');
legend('Magnitude', 'Phase');
hold off;
% Step 6: Impulse Response
subplot(2, 2, 3);
impz(numerator, denominator);
title('Impulse Response');

% Step 7: Filter Coefficients


subplot(2, 2, 4);
stem(0:length(numerator)-1, numerator, 'b', 'LineWidth', 2, 'Marker', 'o');
hold on;
stem(1:length(denominator)-1, denominator(2:end), 'r', 'LineWidth', 2,
'Marker', 'x');
title('Filter Coefficients');
legend('Numerator', 'Denominator');
xlabel('Coefficient Index');
ylabel('Coefficient Value');
grid on;
hold off;

% Step 8: Difference Equation


disp('Difference Equation:');
disp(['y[n] = ' num2str(numerator(1)) 'x[n] + ' num2str(numerator(2)) 'x[n-1]
- ' num2str(denominator(2)) 'y[n-1] - ' num2str(denominator(3)) 'y[n-2]']);

% Step 9: Filtered Output


% (Apply the filter to a test signal)

% Step 10: Listen and Analyze


% (Listen to the filtered output and compare to the original signal)

Difference Equation:
y[n] = 0x[n] + 0x[n-1] - 1.2246e-16y[n-1] - -1y[n-2]

Discussion:
The task involves designing an IIR filter using the Pole-Zero placement method with specific
passband at pi/2 and stopbands at 0 and pi. The provided MATLAB code generates a 2nd order
Butterworth filter and includes plots for pole-zero diagram, frequency response (magnitude and
phase), impulse response, and filter coefficients. The difference equation is also displayed, offering
insights into the filter's temporal behavior.
NED University of Engineering & Technology
Department of _____________________ Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date
NED University of Engineering & Technology
Department of Electrical Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date
(Open Ended Lab Part 01)

Objective:

To convert an analog (voltage & current) signal into digital signal using ADC
(audio card) and display it on MATLAB Simulink environment.

Required Components:

1. Audio Card
2. Transformer (220V/12V)
3. Resistors (for VDR)
4. Veroboard
5. Audio jack
6. PC with MATLAB environment

Procedure:

• Using Transformer convert 220VAC from mains into 12VAC.


• Using VDR convert 12VAC to a voltage compatible to audio card (show all the
calculations of resistances with their power ratings).
• Set the sampling frequency of the audio card ADC in MATLAB Simulink
environment with proper justification
• Plot the acquired voltage waveform to Simulink scope.
• Mention the safe operating range of your equipment.

Project Summary: (Not more than one sheet)


Project Specification:

Calculations:

• VDR and Resistance power calculation


• Resolution of ADC
• Sampling Frequency
• Gain Factor

Attachments:
• Project Block Diagram
• Real Project Image
• Image of current and voltage plot (with proper labelling)
Digital Signal Processing (EE-394)
Electrical Engineering Department

Course Code: EE-394


Course Name: Digital Signal Processing
Semester:
Year:
Section:
Batch:
Lab Instructor name:
Submission
deadline:
OEL Statement:
To convert an analog (voltage & current) signal into digital signal using ADC and display it on
MATLAB Simulink environment.

Deliverables:
1) A Prototype hardware that can read Analog signals (voltage & Current ) and can display it on any
digital environment.

2) A report containing details related to ADC and hardware specification.

Methodology:
1) Using Transformer convert 220VAC from mains into 12VAC.
2) Using VDR convert 12VAC to a voltage compatible to ADC (show all the calculations of resistances
with their power ratings).
3) Set the sampling frequency of the ADC.
4) Plot the acquired voltage waveform to Simulink or any digital environment.
5) Mention the safe operating range of your equipment.

Guidelines:
Figures, Tables, Block Diagrams etc. should be clear with necessary details.

Lethal voltages (above 50 V) must be properly insulated

1
NED University of Engineering & Technology
Department of Electrical Engineering

Course Code and Title: _______________________________________________________________

Laboratory Session: No._______________________________ Date: ____________________

Psychomotor Domain Assessment Rubric-Level P3


Skill Sets Extent of Achievement
0 1 2 3 4
Equipment Not able to identify Able to identify
Identification Sensory the equipment. equipment as well as
skill to identify equipment -- -- -- its components.
and/or its component for a
lab work.
10 % 0 40
Equipment Use Never describes the Rarely able to describe Occasionally Often able to Frequently able to
Sensory skills to describe use of equipment. the use of equipment. describe the use describe the use describe the use of
the use of the equipment of equipment. of equipment. equipment.
for the lab work.
15% 0 15 30 45 60

Procedural Skills Not able to either Able to slightly Able to Able to Able to fully
Displays skills to act upon learn or perform lab understand lab work somewhat moderately understand lab work
sequence of steps in lab work procedure. procedure and perform understand lab understand lab procedure and
work. lab work. work procedure work procedure perform lab work.
and perform lab and perform lab
work. work.
15% 0 15 30 45 60

Response Not able to imitate the Able to slightly imitate Able to Able to Able to fully imitate
Ability to imitate the lab lab work. the lab work. somewhat moderately the lab work.
work on his/her own. imitate the lab imitate the lab
work. work.
15% 0 15 30 45 60

Observation’s Use Not able to use lab Able to slightly use lab Able to Able to Able to fully use lab
Displays skills to perform work observations work observations into somewhat use moderately use work observations
related mathematical into mathematical mathematical lab work lab work into mathematical
calculations using the calculations. calculations. observations observations calculations.
observations from lab into into
work. mathematical mathematical
calculations. calculations.
15% 0 15 30 45 60

Safety Adherence Doesn’t adhere to Slightly adheres to Somewhat Moderately Fully adheres to
Adherence to safety safety procedures. safety procedures. adheres to safety adheres to safety safety procedures.
procedures. procedures. procedures.
10% 0 10 20 30 40

Equipment Handling Doesn’t handle Rarely handles Occasionally Often handles Handles equipment
Equipment care during the equipment with equipment with handles equipment with with required care.
use. required care. required care. equipment with required care.
required care
10% 0 10 20 30 40

Group Work Never participates. Rarely participates. Occasionally Often Frequently


Contributes in a group- participates and participates and participates and
based lab work. contributes. contributes. contributes.
10% 0 10 20 30 40

Total Points (Out of 400)

Weighted CLO (Psychomotor Score) (Points /4)

Remarks

Instructor’s Signature with Date:


NED University of Engineering & Technology
Department of _____________________ Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date
(Open Ended Lab Part 02)

Objective:
To convert analog (Voltage and current) signal into digital signal using ADC
(audio card). Display it on MATLAB Simulink environment and perform
Spectral Analysis of the resulting current signal.
Required Components:
1. Audio Card
2. Current Sensor (current sensing resistor / hall effect sensor / CT)
3. Vero board
4. Audio jack
5. Harmonic producing Load (Electronic devices)
6. PC with MATLAB environment

Procedure:
➢ Using current sensor, convert the current flowing through load into an equivalent voltage.
➢ If required, using VDR to convert the voltage as obtained from current sensor to a voltage
compatible to audio card (show all the calculations of resistances with their power
ratings).
➢ Set the sampling frequency of the audio card ADC in MATLAB Simulink environment
with proper justification
➢ Plot the acquired current waveform to Simulink scope.
➢ Mention the safe operating range of your equipment.
➢ Plot the frequency spectrum of the obtained current and Voltage waveform. Use
windowing function to reduce DFT leakage if required.
➢ Also, plot the frequency spectrum of the line voltage as obtained in open ended lab 01.

Project Summary:

Project Specification:

Attachments:
• Project Block Diagram
• Real Project Image
• Image of current and voltage plot and Spectrum(with proper labelling)

Results:
Digital Signal Processing (EE-394)
Electrical Engineering Department

Course Code: EE-394


Course Name: Digital Signal Processing
Semester:
Year:
Section:
Batch:
Lab Instructor name:
Submission deadline:
OEL Statement:
To perform spectral analysis of the signals acquired in OEL 1.

Deliverables:
1) A Prototype hardware that can read Analog signals (voltage & Current) and can perform spectral
analysis of the acquired signals

2) A report containing details related to spectral analysis of the acquired signals.

Methodology:
1) Plot the frequency spectrum of the obtained current and Voltage waveform.

2)Use windowing function to reduce DFT leakage if required.

Guidelines:
Figures, Tables, Block Diagrams etc. should be clear with necessary details.

Lethal voltages (above 50 V) must be properly insulated

1
NED University of Engineering & Technology
Department of Electrical Engineering

Course Code and Title: _______________________________________________________________

Laboratory Session: No._______________________________ Date: ____________________

Psychomotor Domain Assessment Rubric-Level P3


Skill Sets Extent of Achievement
0 1 2 3 4
Equipment Not able to identify Able to identify
Identification Sensory the equipment. equipment as well as
skill to identify equipment -- -- -- its components.
and/or its component for a
lab work.
10 % 0 40
Equipment Use Never describes the Rarely able to describe Occasionally Often able to Frequently able to
Sensory skills to describe use of equipment. the use of equipment. describe the use describe the use describe the use of
the use of the equipment of equipment. of equipment. equipment.
for the lab work.
15% 0 15 30 45 60

Procedural Skills Not able to either Able to slightly Able to Able to Able to fully
Displays skills to act upon learn or perform lab understand lab work somewhat moderately understand lab work
sequence of steps in lab work procedure. procedure and perform understand lab understand lab procedure and
work. lab work. work procedure work procedure perform lab work.
and perform lab and perform lab
work. work.
15% 0 15 30 45 60

Response Not able to imitate the Able to slightly imitate Able to Able to Able to fully imitate
Ability to imitate the lab lab work. the lab work. somewhat moderately the lab work.
work on his/her own. imitate the lab imitate the lab
work. work.
15% 0 15 30 45 60

Observation’s Use Not able to use lab Able to slightly use lab Able to Able to Able to fully use lab
Displays skills to perform work observations work observations into somewhat use moderately use work observations
related mathematical into mathematical mathematical lab work lab work into mathematical
calculations using the calculations. calculations. observations observations calculations.
observations from lab into into
work. mathematical mathematical
calculations. calculations.
15% 0 15 30 45 60

Safety Adherence Doesn’t adhere to Slightly adheres to Somewhat Moderately Fully adheres to
Adherence to safety safety procedures. safety procedures. adheres to safety adheres to safety safety procedures.
procedures. procedures. procedures.
10% 0 10 20 30 40

Equipment Handling Doesn’t handle Rarely handles Occasionally Often handles Handles equipment
Equipment care during the equipment with equipment with handles equipment with with required care.
use. required care. required care. equipment with required care.
required care
10% 0 10 20 30 40

Group Work Never participates. Rarely participates. Occasionally Often Frequently


Contributes in a group- participates and participates and participates and
based lab work. contributes. contributes. contributes.
10% 0 10 20 30 40

Total Points (Out of 400)

Weighted CLO (Psychomotor Score) (Points /4)

Remarks

Instructor’s Signature with Date:


NED University of Engineering & Technology
Department of _____________________ Engineering

Course Code: EE-395 Course Title: Digital Signal Processing


Laboratory Session No.: ________________________ Date: ______________________________
Psychomotor Domain Assessment Rubric for Laboratory (Level P3)
Skill(s) to be Extent of Achievement
assessed 0 1 2 3 4
Software Menu Unable to Little ability and Moderate Reasonable Demonstrates
Identification and understand understanding ability and understanding of command over
Usage: and use of software understanding software menu software menu
Ability to initialise, software menu of software operation, makes usage with
configure and menu operation, menu no major mistakes frequent use of
operate software makes many operation, advance menu
environment under mistake makes lesser options
supervision, using mistakes
menus, shortcuts,
instructions etc.
Procedural Little to no Slight ability to Mostly correct Correctly Correctly
Programming of understanding use procedural recognition and recognises and recognises and
given Signal of procedural programming application of uses procedural uses procedural
Processing Scheme: programming techniques for procedural programming programming
Practice procedural techniques coding given programming techniques with techniques with
programming algorithm techniques but no errors but no errors and runs
techniques, in order makes crucial unable to run processing
to code specific errors for the processing successfully
signal processing given processing scheme
schemes scheme successfully
Relating Theoretical Completely Able to Able to Able to recognise Able to recognise
Concepts, unable to recognise some recognise relation between relation between
Equations and relate relation relation signal processing signal processing
Transforms to between between signal between signal concepts and concepts and
Code: signal processing processing written code, able written code, able
Recognise relation processing concepts and concepts and to do some to completely
between signal concepts and written code, written code, manipulations manipulate code
processing concepts written code, unable to do unable to do in line with
and written code unable to do manipulations manipulations theoretical
and manipulate the manipulations concepts
code in accordance
of requirements
Detecting and Unable to Able to find Able to find Able to find error Able to find error
Removing Errors: check and error messages error messages messages in messages in
Detect detect error and indications and indications software as well as software along
Errors/Exceptions messages and in software but in software as understanding of with the
and in simulation indications in no well as detecting all of understanding to
and manipulate software understanding understanding those errors and detect and rectify
code to rectify the of detecting of detecting their types them
simulation those errors some of those
and their types
errors and their
types
Graphical Unable to Ability to Ability to Ability to Ability to
Visualisation and understand understand and understand and understand and understand and
Comparison of and utilise utilise utilise utilise utilise
Signal Processing visualisation or visualisation visualisation visualisation and visualisation and
Scheme plotting and plotting and plotting plotting features plotting features
Parameters: features features with features successfully, successfully, also
Manipulate given frequent errors successfully but partially able to able to compare
simulation under unable to compare and and analyse them
supervision, in order compare and analyse them
to produce analyse them
graphs/plots for
measuring and
comparing signal
processing
parameters
Following step-by- Inability to Able to Able to Able to recognise Able to recognise
step procedure to recognise and recognise given recognise given given lab given lab
complete lab work: perform given lab procedures lab procedures procedures and procedures and
Observe, imitate lab procedures and perform and perform perform them by perform them by
and operate them but could them by following following
software to not follow the following prescribed order prescribed order
complete the prescribed prescribed of steps, with of steps, with no
provided sequence order of steps order of steps, occasional mistakes
of steps with frequent mistakes
mistakes
Recording Inability to Able to Able to recognise Able to recognise
Simulation recognise recognise prescribed or prescribed or
Observations: prescribed or prescribed or required required
Observe and copy required required simulation simulation
prescribed or simulation simulation measurements measurements
required simulation measurements measurements __ but records them and records them
results in but does not incompletely completely, in
accordance with lab record tabular form
manual instructions according to
given
instructions
Discussion and Complete Slight ability to Moderate Reasonable ability Full ability to
Conclusion: inability to discuss ability to discuss to discuss discuss recorded
Demonstrate discuss recorded recorded recorded observations and
discussion capacity recorded observations observations observations and draw conclusions
on the recorded observations and draw and draw draw conclusions
observations and and draw conclusions conclusions
draw conclusions conclusions
from it, relating
them to theoretical
principles/concepts
Weighted CLO (Psychomotor Score)
Remarks
Instructor’s Signature with Date

You might also like