Digital Signal Processing Lab Manual
Digital Signal Processing Lab Manual
LAB MANUAL
Student name:
Roll no: Batch:
Semester: Year:
Introduction
This lab is to familiarize the students with t h e MATLAB environment, through which some
preliminary MATLAB functions will also be covered.
Procedure:
Students are required to go through the steps explained below and then complete the exercises
given at the end of the lab.
1. Introduction to MATLAB
a. To add a comment, the following symbol is used: "%".
b. Help is provided by typing “help” or, if you know the topic, then “help function_name” or “doc
function_name”.
c. If you don't know the exact name of the topic or command you are looking for, type "lookfor
keyword" (e.g., "lookfor regression")
d. Three dots “...” are used to continue a statement to the next line (row).
e. If after a statement, “;” is entered, then MATLAB will not display the result of the statement
entered; otherwise result would be displayed.
f. Use the up-arrow to recall commands without retyping them (and down arrow to go forward in
commands).
g. MATLAB is case sensitive, so “UET” is not t h e same as “uet”
If there are several alternatives, one should use the following construction
if expression1
commands (evaluated if expression 1 is true) elseif expression 2
commands (evaluated if expression 2 is true) elseif …...
else
commands (executed if all previous expressions evaluate to false)
end
The syntax of the switch-case construction is switch expression (scalar or string)
case value1 (executes if expression evaluates to value1)
commands
case value2 (executes if expression evaluates to value2)
commands
...
otherwise statements
end
Switch compares the input expression to each case value. Once the %match is found, it executes the
associated commands. In the following example, a random integer number x from the set {1, 2, …,
10} is generated. If x = 1 or x = 2, then the message Probability = 20% is displayed on the screen.
If x = 3 or 4 or 5, then the message Probability = 30 is displayed; otherwise, the message Probability
= 50% is generated. The script file fswitch utilizes a switch as a tool
%for handling all cases mentioned above
% Script file fswitch.
x = ceil(10*rand); % Generate a random integer in {1, 2, ... , 10} switch x
case {1,2}
disp('Probability = 20%');
case {3,4,5}
disp('Probability = 30%'); otherwise
disp('Probability = 50%');
end
Note: Use of the curly braces after the word case. This creates the so-called cell array rather than
the one-dimensional array, which %requires the use of the square brackets.
To open the m-file from within the Command Window, type edit firstgraph %and then press
Enter or Return key. Here is an example of a small script file
% Script file firstgraph.
x = -10*pi:pi/100:10*pi; y = sin(x)./x;
plot(x,y) grid
Enter this code in the MATLAB editor and save it as firstgraph.m. This function can be called
from the command line as
firstgraph
Here is an example of a function file
function [b, j] = descsort(a)
% Function descsort sorts, in descending order, a real array a.
% Second output parameter j holds a permutation used to obtain
% array b from the array a. [b,j] = sort(-a);
b = -b;
Enter this code in the MATLAB editor and save it as descsort.m. This function can be called from
the command line as
X=1:10
descsort(X)
7. Graphs in MATLAB
Save the script file and then run it
Script file graph1.
Graph of the rational function y = x/(1+x^2).
for n=[Link]
n10 = 10*n;
x = linspace(-2,2,n10); y = x./(1+x.^2);
plot(x,y,'r')
title(sprintf('Graph %g. Plot based upon n = %g points.' ... ,(n+1)/2, n10)) axis([-2,2,-.8,.8])
xlabel('x')
ylabel('y') grid pause(3)
end %Several graphs using subplot
graph1
Signals are broadly classified into continuous and discrete signals. A continuous signal will be
denoted by x(t), in which the variable t can represent any physical quantity. A discrete signal will
be denoted x[n], in which the variable n is an integer value. In this lab, we will learn to represent
and operate on signals in MATLAB. The variables t and n are assumed to represent time.
b. Signal multiplication
It is implemented in MATLAB by the array operator “.*”. To multiply sequences of
different lengths, we can use the following function
function [y,n] = sigmult(x1,n1,x2,n2)
% y(n) = x1(n) * x2(n)
n = min(min(n1),min(n2)):max(max(n1),max(n2));
y1 = zeros(1,length(n)); y2 = y1;
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2; y = y1 .* y2;
c. Shifting
In this operation, each sample of x(n) is shifted by an amount k to obtain a shifted sequence
y(n):
Y(n) = {x(n − k)}
If we let 𝑚 = 𝑛 − 𝑘, then 𝑛 = 𝑚 + 𝑘 and the above operation is given by
Y(m + k) = {x(m)}
For this, we can use the following function
function [y,n] = sigshift(x,m,n0)
% y(n) = x(n-n0)
n = m+n0; y = x;
d. Folding
In this operation, each sample of 𝑥(𝑛) is flipped around n=0 to obtain a folded sequence 𝑦(𝑛)
Y(n) = {x(−n)}
For this the following function is shown
function [y,n] = sigfold(x,n)
% y(n) = x(-n)
y = fliplr(x); n= -fliplr(n);
e. Up sampling
% Original signal
x = [1 2 3 4 5];
% Upsample by a factor of L (e.g., L=3)
L = 3;
y = upsample(x, L);
% Display the original and upsampled signals
disp('Original signal x:');
disp(x);
disp(['Upsampled signal y (factor ', num2str(L), '):']);
disp(y);
% Plotting for visualization
stem(x, 'filled', 'DisplayName', 'Original Signal');
hold on;
stem((0:length(y)-1)/L, y, 'DisplayName', 'Upsampled Signal'); % Adjust x-
axis for upsampled signal
title('Upsampling a Discrete Signal');
xlabel('Sample Index');
ylabel('Amplitude');
legend;
grid on;
f. Down sampling
% Original signal (e.g., the upsampled signal from the previous example)
x_upsampled = [1 0 0 2 0 0 3 0 0 4 0 0 5]; % Example: upsampled by 3
% Downsample by a factor of M (e.g., M=3)
M = 3;
z = downsample(x_upsampled, M);
% Display the original (upsampled) and downsampled signals
disp('Original (upsampled) signal x_upsampled:');
disp(x_upsampled);
disp(['Downsampled signal z (factor ', num2str(M), '):']);
disp(z);
% Plotting for visualization
stem(x_upsampled, 'filled', 'DisplayName', 'Original (Upsampled) Signal');
hold on;
stem(0:M:(length(x_upsampled)-1), z, 'DisplayName', 'Downsampled Signal');
% Adjust x-axis for downsampled signal
title('Downsampling a Discrete Signal');
xlabel('Sample Index');
ylabel('Amplitude');
legend;
grid on;
4. Exercises:
Generate and plot each of the following sequences over the indicated interval. Provide
the scripts used to generate the plots. For the exercises, use the functions in step 4.
1.
a. Z(n) = 2δ(n+2) – δ(n-4), -5 ≤ δ ≤ 5
b. X(n) = n[u(n)-u(n-10)] + 10 e-0.3(n-10)[u(n-10) – u(n-20)], 0 ≤ n ≤ 20
2. Let x(n) = {1,2,3,4, 5, 6, 7, 6, 5, 4, 3, 2, 1}. Determine and plot the following
sequences.
a. x1(n) = 2x(n-5) – 3x(n+4)
b. x2(n) = x(3-n) + x(n)x(n-2)
LAB SESSION 03
OBJECTIVE:
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.
An analog phenomenon is continuous, like a human speech of speaker, or a continuously rotating
disc attached to the shaft of a 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. A 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 a sampled/discrete phenomenon (signal) can be calculated as
𝑓𝑑 = 𝐹 /𝐹𝑠 (cycles/sec )/(samples/sec) = cycles/ samples
Where, F = Frequency of analog or continuous phenomenon (signal). [Unit: cycles/sec]
𝐹𝑠 = Sampling frequency or sampling rate [Unit: samples/sec]
𝑓𝑑 = Frequency of a Discrete phenomenon (signal). [Unit: cycles/sample]
Sampling Theorem: A continuous-time phenomenon or signal like x(t) can be reconstructed
exactly from its samples 𝑥(𝑛) = 𝑥(𝑛𝑇𝑠), if the samples are taken at a rate 𝐹𝑠 = 1/𝑇𝑠, that is
greater than twice the frequency of the signal being sampled, i.e., 𝐹𝑠 ≥ 2 ∗ 𝐹.
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 (𝑓𝑑 > 1/2 cycles/sample).
PROCEDURE:
1. Simulate and plot two CT signals of 10 Hz and 110 Hz for 0 < 𝑡 < 0.2 secs.
2. Sample at 𝐹𝑠 = 100 Hz and plot them in discrete form.
3. Observe and note the aliasing effects.
4. Explore and learn.
STEPS:
1. Make a folder on the 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 (2piF0 t). The sampled version will be:
x(n) = sin (2piF0 /F0 n),
where 𝑛 is a set of integers, and the sampling interval Ts = 1/Fs.
a. Plot the signal 𝑥(𝑛) for n = 0 to 99 for 𝐹𝑠 = 5 𝑘𝐻𝑧 and 𝐹0 = 0.5, 2, 3 and 4.5 kHz.
b. Explain the similarities and differences among various plots.
a) Generate a tone in MATLAB with varying frequency f = 1000,2000,3000,4000, 5000, 6000, 8000,
9000, 25000, -1000, -2000, -3000 Hz with 𝐹𝑠 = 8000 samples/sec. Listen to the tones, and observe
at sound like what frequency? Also specify whether Aliasing is happening or not.
2. 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 04
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 the
digitized signal. The method of selection of ADC is also a part of this lab session.
THEORY:
Everything stored on a computer is a discrete-time time discrete-valued signal. Because a computer has a
finite number of registers, 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 a very fine resolution
of the amplitude axis to give the effect of a continuous valued signal, but due to the 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 signals usually involves
two stages: sampling, i.e., the measurement of t h e 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 a b-bit is 2𝑏 . The largest decimal number that
can be represented with an 𝑏-bit binary number is 2𝑏 − 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 28 = 256 different discrete levels at which samples can be
approximated or recorded. Eight bits together constitute one byte. A bit depth of 16 allows 216 =
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 × 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, 23 = 8 quantization
levels ranging from −4 𝑡𝑜 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 2𝑏−1 − 1, levels are above the horizontal axis. Note that since one bit is used for the signed bit
(in 2-complement format), the largest magnitude corresponds to 2𝑏−1. (not 2𝑏 ). 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 into 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 be stored 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 the round-off method is used). 𝑋𝑒(𝑛) = 𝑋𝑞(𝑛) − 𝑥(𝑛). 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 that 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.
𝑆𝑁𝑅 = 10𝑙𝑜𝑔10 (𝑃𝑥 /𝑃𝑒 )
Where, 𝑃𝑥, and 𝑃𝑒 are the 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 boards 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 a 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 general 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 to 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 referred to as signal-to-quantization-noise ratio (SQNR), but it is essential to note 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. Whenever we digitize our signal, we will always have a
quantization error. Quantization error represents the quality of the quantization process, but the total
error may also turn out to be zero, so signal-to-quantization-noise-ratio (SQNR) is used to describe
the quality of quantization process and it can be defined as
𝑆𝑄𝑁𝑅𝐴/𝐷 = 10 𝑙𝑜𝑔 10(𝑃𝑥 /𝑃𝑒)
Where, 𝑷𝒙~and 𝑷𝒆 are t h e average power of the DTCV (sampled) signal and t h e quantization
error signal, respectively.
PROCEDURE:
1. Simulate a DTCV sinusoid of 1/50 cycles/sample with a signal length of the signal be 500.
2. Choose the no. of significant digits for round-off and apply it to the signal generated above.
3. Compute the error signals and SQNR
4. Explore and observe.
STEPS:
1. Make a folder at the 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 it 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 a n d 𝑓𝑑2 = 150
samples/sec with a signal length of 250 samples.
Take the desired number of significant digits from the user as input. Then choose the method of
Quantization (round-off, floor & ceil) and apply it 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 the
corresponding plots. You can use a 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 the 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 the number of bits for audio
until quality stops improving.
LAB SESSION 05
OBJECTIVE:
To study the impulse response, observe the convolution technique in signal processing and verify
various properties, including causality, commutativity, distributivity, and associativity.
THEORY:
RESULT:
EXERCISE:
1. What will happen if we input 𝑥(𝑛) = {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 the Associative and Distributive properties of the convolution.
4. Convolve your recorded sound with [Link]. Note your observation
a) Plot the output.
b) Listen to the output
LAB SESSION 06
OBJECTIVE:
To study discrete-time correlation and apply it to real data to observe the correlation between
two signals.
THEORY:
∞ ∞
OBJECTIVE:
𝑋[𝑘] = ∑ 𝑥[𝑛]𝑊𝑁𝑘𝑛 , 0 ≤ 𝑘 ≤ 𝑁 − 1
𝑛=0
where:
• 𝑥(𝑛): Input signal (time domain)
• 𝑋(𝑘): Output signal (frequency domain)
𝑁−1
1
𝑥[𝑛] = 𝑁
∑ 𝑋[𝑘]𝑊𝑁−𝑘𝑛 , 0 ≤ 𝑘 ≤ 𝑁 − 1
𝑛=0
Note: This recovers the original signal from its frequency components.
2𝜋
Where 𝑊𝑁 = 𝑒 −𝑗 𝑁 . Which is an Nth root of unity. 𝑊𝑁 is called Twiddle Factor, also generic form of the
2𝜋𝑘
twiddle factor is: 𝑊𝑁𝑘𝑛 = 𝑒 −𝑗 𝑁
𝑛
. The Matrix form of the DFT and IDFT are as follow:
𝐗 = 𝐃𝑁 𝐱
where
𝑇
𝐗 = [𝑋[0] 𝑋[1] … 𝑋[𝑁 − 1]]
𝑇
𝐱 = [𝑥[0] 𝑥[1] … 𝑥[𝑁 − 1]]
1 1 1 … (𝑁 1
−1)
1 𝑊𝑁 1
𝑊𝑁 … 𝑊𝑁
2
−
𝐃𝑁 = 1 𝑊𝑁2 𝑊𝑁4 … 𝑊𝑁2(𝑁 1)
⋮ ⋮ ⋮ ⋱ ⋮
(𝑁−1) 2(𝑁−1) ⋯ (𝑁−1)2
1 𝑊𝑁 𝑊𝑁 𝑊𝑁
[ ]
−1
𝒙 = 𝑫 𝑁 𝑿
−1
𝐃
where 𝑁 is the N × N IDFT matrix
PROCEDURE:
TASK
Compute 4 point DFT of x(n)= ( 1,2,3,0).
STEPS
1. Generate the 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=[Link]N-1];
k=[Link]N-1];
WN=exp(-j*2*pi/N); nk=n'*k; WNnk=WN.^nk; Xk=x*WNnk
LAB TASK
Prove the DFT synthesis equation using the DFT output generated from the lab task.
LAB SESSION 08
OBJECTIVE:
To observe/find different frequency components in an audio signal and plot it with different x-axes.
THEORY:
𝟐𝝅𝒌
• DFT analysis Equation; 𝑿[𝒌] = 𝑿(𝒆𝒋𝒘 )|𝝎=𝟐𝝅𝒌 = ∑𝑵−𝟏
𝒏=𝟎 𝒙[𝒏]𝒆
−𝒋 𝑵
𝒏
,𝟎 ≤ 𝒌 ≤ 𝑵 − 𝟏
𝑵
Note: 𝑿(𝒆𝒋𝝎 ) = ∑∞
𝒏=−∞ 𝒙(𝒏)𝒆
−𝒋𝝎𝒏
𝒂𝒏𝒅 𝝎 = 𝟐𝝅𝒇 = (𝟐𝝅
𝑵
)𝒌
𝟐𝝅𝒌
• DFT Synthesis Equation: 𝒙[𝒏] = 𝑵𝟏 ∑𝑵−𝟏 𝒋 𝒏
𝒏=𝟎 𝑿[𝒌]𝒆 𝑵 , 𝟎 ≤ 𝒌 ≤ 𝑵 − 𝟏
• Frequency Resolution is given by ∆𝑭 = 𝑭𝑵𝑺
• Sample frequencies are given by 𝑭𝒌 = ∆𝑭 × 𝒌, 𝒌 = 𝟎, 𝟏, … , 𝑵 − 𝟏
PROCEDURE:
1. Load an audio file ‘[Link]’ 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 the desktop and name it as your current directory within MATLAB.
2. Copy the audio file ‘[Link]’ into your current directory.
3. Open the M file editor and write the following code:
clear all; clc; close all;
[y,Fs,bits] = wavread('[Link]');
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:
OBJECTIVE:
To study the s-plane and plot the impulse and frequency response for different pole-zero locations
in the s-plane. Also, to determine whether the system is FIR or IIR.
THEORY:
The Laplace Transform of a general continuous time signal x (t) is defined as;
𝑋(𝑆) = ∫ 𝑥(𝑡)𝑒 −𝑠𝑡 𝑑𝑡
Where the complex variable 𝑠 = 𝛿 + 𝑗ω, 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 the pole lies on the L.H.S. of the
s-plane, the system is stable. If the pole lies on the R.H.S. of the s-plane, the system is unstable. If
the pole lies on 𝑦(𝑜𝑟 𝑗𝜔) − 𝑎𝑥𝑖𝑠. Then the system is marginally stable or oscillatory. If the system
has an FIR, it is stable. If the system is IIR, it can be stable or unstable.
PROCEDURE:
Generate a pole-zero constellation in the s-plane.
1. Plot the corresponding Frequency (Bode magnitude) response.
2. Plot impulse response and determine that the system is FIR or IIR.
3. Modify the location of poles in the s-plane to observe the corresponding change in
frequency and impulse response.
STEPS.
1. Make a folder on the desktop and name it as your current directory within MATLAB.
2. Open the 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 the L.H.S of the s-plane to the y-axis first, and then to the R.H.S of s-plane,
and observe the effects.
LAB SESSION 10
OBJECTIVE:
To study the z-plane and plot impulse and frequency response for different pole-zero locations in
the z-plane. Also, to determine whether the system is FIR or IIR.
THEORY:
The z - Transform of a general discrete time signal x(n) is defined as;
∞ ∞
−𝑛 −𝑛
𝑋(𝑧) = ∑ 𝑥[𝑛] 𝑧 = ∑ 𝑥[𝑛] (𝑟𝑒 𝑗𝜔 )
𝑛=−∞ 𝑛=−∞
Where the complex variable 𝑧 = 𝑟 ∠𝜔 , with r the radius and 𝜔 the angle. DTFT is a subset of
𝑧 transform when r =1. Since ‘𝑟’ information is not present in DTFT; therefore, information about
stability in discrete time can only be obtained from the z-transform. If the pole lies inside the unit
circle, the system is stable. If the pole lies outside the unit circle, the system is unstable. If the pole
lies at the unit circle, the system is marginally stable or oscillatory. If the system has an FIR, it is
stable. If the system is IIR, it can be stable or unstable.
PROCEDURE:
1. Generate a pole-zero constellation in the z plane.
2. Plot the corresponding Frequency (Bode magnitude) response.
3. Plot impulse response and determine that the system is FIR or IIR.
4. Modify the location of poles in the z plane to observe the corresponding change in
frequency and impulse response.
STEPS:
1. Make a folder on the desktop and name it as your current directory within MATLAB.
2. Open the 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;
4. 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 the poles from inside the unit circle to outside and at the unit circle, and observe
and note the changes.
LAB SESSION 11
OBJECTIVE:
The objective of this lab is to introduce digital filters and their types, design an FIR filter, and
investigate how it performs filtering on a signal. Furthermore, truncate different types of FIR
filters, such as Low Pass, High Pass, and Band Pass, using various windows, including rectangular
and Kaiser, and compare the results obtained from each window.
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 that can be used to design digital filters like IIR and FIR.
PROCEDURE:
TASK-1
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 a 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 the Hamming and Kaiser Window.
Compare the results of the designed filters using three different windows on a single plot.
LAB SESSION 12
OBJECTIVE:
The object of this lab is to design different IIR filters using the FDA tool.
THEORY:
Filter Design and Analysis Tool (FDA Tool) is a graphical user Interface for designing and
analyzing filters. It is used to design FIR and IIR filters by entering the desired filter specifications,
importing a filter from MATLAB workspace, or adding, moving, or deleting poles and zeros. After
designing a filter, the response can be viewed and analyzed in another Graphical User Interface
tool named the Filter Visualization Tool (FV Tool) linked with the 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
Figure A
The different steps involved in designing a filter using the FDA Tool can be listed as:
1. Selection of the type of response required
2. Selection of the 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, t h e filter can be designed, and its response can
be viewed and analyzed. The complete description of the FDA Tool window and the 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, high-pass, bandpass, band-stop, differentiation, multiband, peaking,
etc.
2. Type of design method: The design can be of an FIR or an 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 the dropdown menu are as
follows:
• 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 squares
• Window
• Const least squares
• Complex Equirriple
• Least Pth norm
• Constrained Equirriple
• Generalized Equirriple
• Constrained band Equirriple
• Interpolated FIR
The options available depend upon the selection of response type.
3. Filter order: Under this, two options are available as
1. User-defined order: Under this option user has to enter the order of the filter.
2. Minimum order: The other option available for selecting the filter order is the minimum order.
It is calculated by the system itself.
4. Filter specifications: Depending upon the response type and design method selected, the graphical
representation of generalized filter specifications appears in the display region of the FDA Tool.
These specifications are ‘Frequency Specifications’ and ‘Magnitude Specifications’. These
specifications are provided by the user, as per the filter design requirement, in the appropriate
blocks.
5. Designing a 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 the 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 calculated as per the specifications
provided by the user, the display region will show the magnitude response of the designed filter.
The other filter response characteristics can be viewed in the display region or the FV Tool. The
response to be viewed can be selected from the different icons displayed on the toolbar shown in
the Figure below. Figure: Different Response Icons on the Toolbar
(NOTE: The different responses for display can also be selected from the ‘Analysis’ menu on the
menu bar.)
7. Current filter information: The information about the designed filter is given in the ‘Current Filter
Information’ region of the FDA Tool window, as shown in Figure A The information provided is
about the ‘structure’, ‘order’, ‘stability’, and ‘source’
o Storing a filter: The designed filter is stored by clicking the ‘Store Filter’ button in the ‘Current
Filter Information’ region.
o 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 the ‘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 a MAT-file and
can be used later on. It can be saved by clicking the save icon or selecting the save session
option in the File menu and giving the desired session name. Similarly, the saved session can be
opened by clicking the open icon or by selecting the open option in the 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 the ‘View’ menu or clicking the ‘Full View Analysis’ button on the toolbar.
The FV Tool window is shown in Figure C. The FV Tool has most of the menus on the menu bar and
icons on the toolbar, similar to the FDA Tool, with some additional icons that are mainly used to work
with the representation of the responses.
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 i s 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 the new FDA Tool window
as shown in the Figure. FDA Tool Window Showing Specification Entered and Magnitude Response
for Task-1. The filter is designed for a minimum order so as to reduce the complexity of the
design. In case it has to be designed for user user-defined order, then the order of the filter has to be
calculated first by the user using appropriate formulas or MATLAB function.
The other responses can be viewed by clicking on the appropriate icon on the toolbar, and the
responses obtained are shown in the Figures below:
Figure Magnitude Response in dB
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.
2. To obtain the information about the filter ‘Filter Information’ icon on the Toolbar of
the FDA Tool Window is clicked, or the ‘Filter Information’ option is selected from
the ‘Analysis’ menu. The detailed filter information appears in the display region as
shown in Figures 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 turning on any motor in your house. Design a filter using
the FDA Tool. Remove the sound of the motor from the recorded signal. Listen to the output
signal.
LAB SESSION 13
Objective:
To study the computer implementation of the Short-Time Fourier Transform
Introduction
The discrete Fourier transform expresses a signal as a sum of sinusoids. Because the time duration of
the sinusoids is infinite, the discrete Fourier transform of the signal reflects the spectral content of an
entire signal over time but does not indicate when the spectral content occurs. However, in some cases,
evaluating the spectral content of a signal over a short time scale can be useful. You can use the STFT
to evaluate spectral content over short time scales.
The STFT, also called the windowed Fourier transform or the sliding Fourier transform, partitions the
time-domain input signal into several disjoint or overlapped blocks by multiplying the signal with a
window function and then applying the discrete Fourier transform to each block. Window functions,
also called sliding windows, are functions in which the amplitude tapers gradually and smoothly toward
zero at the edges. Because each block occupies different time periods, the resulting STFT indicates the
spectral content of the signal at each corresponding time period. When you move the sliding window,
you obtain the spectral content of the signal over different time intervals. Therefore, the STFT is a
function of time and frequency that indicates how the spectral content of a signal evolves over time
Experiment 1
Step 1
Generate a chirp with sinusoidally varying frequency. The signal is sampled at 10 kHz for two seconds.
fs = 10e3;
t = 0:1/fs:2;
x = vco(sin(2*pi*t),[0.1 0.4]*fs,fs);
Step 2
Compute the short-time Fourier transform of the chirp. Divide the signal into 256-sample segments and window
each segment using a Kaiser window with shape parameter β = 5. Specify 220 samples of overlap between
adjoining segments and a DFT length of 512. Output the frequency and time values at which the STFT is
computed.
[s,f,t] = stft(x,fs,Window=kaiser(256,5),OverlapLength=220,FFTLength=512);
Step 3
The magnitude squared of the STFT is also known as the spectrogram. Plot the spectrogram in decibels. Specify
a colormap that spans 60 dB and whose last color corresponds to the maximum value of the spectrogram.
sdb = mag2db(abs(s));
mesh(t,f/1000,sdb);
cc = max(sdb(:))+[-60 0];
ax = gca;
[Link] = cc;
view(2)
colorbar
Obtain the same plot by calling the stft function with no output arguments.
stft(x,fs,Window=kaiser(256,5),OverlapLength=220,FFTLength=512)
Experiment 2
Step 1
Generate a quadratic chirp sampled at 1 kHz for 2 seconds. The instantaneous frequency is 100
Hz at 𝑡 = 0 and crosses 200 Hz at 𝑡 = 1 second.
ts = 0:1/1e3:2;
f0 = 100;
f1 = 200;
x = chirp(ts,f0,1,f1,"quadratic",[],"concave");
Compute and display the STFT of the quadratic chirp with a duration of 1 ms.
d = seconds(1e-3);
win = hamming(100,"periodic");
stft(x,d,Window=win,OverlapLength=98,FFTLength=128);
Experiment 3
MATLAB example demonstrating how to compute and display the spectrogram of a speech signal:
% 1. Load a speech signal
% You can replace '[Link]' with your own audio file (e.g., 'my_speech.wav')
% If using a .wav file: [y, fs] = audioread('my_speech.wav');
load [Link]; % Loads 'y' (audio data) and 'Fs' (sampling frequency)
% Ensure 'y' is a column vector
y = y(:);
% 2. Define STFT parameters
windowLength = 512; % Length of the analysis window in samples
overlapLength = round(0.75 * windowLength); % Overlap between windows (e.g.,75%)
nfft = windowLength; % Number of FFT points (often equal to window length)
% 3. Compute the spectrogram
% [S, F, T] = spectrogram(x, window, noverlap, nfft, fs)
[S, F, T] = spectrogram(y, windowLength, overlapLength, nfft, Fs);
% 4. Display the spectrogram
figure;
imagesc(T, F, 20*log10(abs(S))); % Display magnitude in dB
axis xy; % Flip the y-axis to have lower frequencies at the bottom
colormap jet; % Use a suitable colormap
colorbar; % Add a color bar for magnitude reference
xlabel('Time (s)');
ylabel('Frequency (Hz)');
title('Spectrogram of Speech Signal');
ylim([0, Fs/2]); % Limit y-axis to Nyquist frequency
Open Ended Lab Part 01
Objective:
To convert an analog (voltage & current) signal into a digital signal using an ADC (audio card) and
display it on the 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 with the audio card (show all
the calculations of resistances with their power ratings).
• Set the sampling frequency of the audio card ADC in the MATLAB Simulink
environment with proper justification
• Plot the acquired voltage waveform to the 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)
Open Ended Lab Part 02
Objective:
To convert an analog (Voltage and current) signal into a digital signal using an ADC (audio card).
Display it on the 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 a current sensor, convert the current flowing through the load into an equivalent voltage.
➢ If required, use VDR to convert the voltage as obtained from the current sensor to a
voltage compatible with the audio card (show all the calculations of resistances with
their power ratings).
➢ Set the sampling frequency of the audio card ADC in the MATLAB Simulink
environment with proper justification
➢ Plot the acquired current waveform in the Simulink scope.
➢ Mention the safe operating range of your equipment.
➢ Plot the frequency spectrum of the obtained current and Voltage waveform. Use a
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:
Page 52 of
2