Lab 1
Lab 1
Ts=1/Fs;
t=[0:0.00000005:0.2];
x1t=cos(2*pi*F1*t);
x2t=cos(2*pi*F2*t);
figure;
plot(t,x1t,t,x2t, 'LineWidth',2);
xlabel('continuous time (sec)');
ylabel('Amplitude');
xlim([0 0.1]);
grid on;
legend('10Hz','110Hz');
title('Two CTCV (analog) sinusoids');
LAB TASKS:
Task 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.
% Clear workspace, command window, and close all figures
clear all;
close all;
% Sampling frequency
Fs = 5000;
Task 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.
RESULT:
We can conclude from the sounds that frequencies from 1 KHz to 4 KHz possess unique properties following
Nyquist criteria and the sound becomes shriller. Aliasing starts happening from 5 KHz to 25 KHz as they take
the identity of other frequencies. The negative frequencies are mirror images of the positive ones and sound the
same as they follow “–Fs/2”.
Task 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
THOUGHTS:
Higher sampling rates generally result in larger file sizes because more samples are taken per second. As
I proceeded to lower frequencies I heard some unexpected sounds, which indicated aliasing. Aliasing is
more likely when the original recording contains frequencies close to or exceeding the Nyquist frequency
of the new sampling rate.
NED University of Engineering &
Technology Department of Electrical
Engineering
% Set parameters
N = 500; % Number of samples
fd = 1/50; % Frequency of the cosine signal
n = 0:499; % Time indices
% Prompt user for the number of digits after the decimal point to be retained
q = input('No. of Digits after decimal points to be retained (0-9): ');
2. Quantization Method :
The choice of quantization method (floor, ceil, round-off) affects how values are rounded during
the quantization process.
Round-off tends to produce values that are closest to the original values.
Floor and ceil introduce biases, rounding down or up, respectively, which may lead to a different
distribution of quantization errors.
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 a column format for plotting (but the
diagrams should be visible)
clear all;
close all;
clc;
xmax = 2^(q - 1) - 1;
xn = xmax * xn;
if qs == 1
xq = round(xn);
elseif qs == 2
xq = floor(xn);
elseif qs == 3
xq = ceil(xn);
end
% Create a new figure for each bit depth
figure;
stem(n, xn, 'r'); % Red for DTCV
xlim([0 99]);
grid on;
hold on;
stem(n, xq, 'k'); % Black for DTDV
xlim([0 99]);
title(['Quantized Signal - ' num2str(q) ' bits']);
legend('DTCV', 'DTDV');
xlabel('Time index');
ylabel('Amplitude');
end
Conclusion:
The straight line in the case of 1-bit quantization represents the limited resolution of the quantized
signal, which can only take two distinct values
As the number of bits per sample increases, the quantization levels become finer. Finer quantization
levels result in a quantized signal closely resembling the original sinusoidal signal.
Higher bit depths generally result in a more accurate representation of the original signal but come at
the cost of increased data storage or transmission requirements.
Lower bit depths introduce quantization errors and may lead to a loss of signal fidelity.
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.
% Load the audio file
file_path = 'E:\voice records lab task matlab dsp\asma 0.wav';
[y, fs] = audioread(file_path);
% Original audio
sound(y, fs);
for i = 1:length(bit_depths)
bit_depth = bit_depths(i);
Thoughts:
At 1- and 2-bit depth there was no sound after that distorted sound is observed. At bit depth 6, 7 and 8 the sound
quality started to increase and at 9 excellent sound quality is observed. So, it is concluded that as we increase the bit
depth the sound quantization interval decreases due to inverse relation.
LAB TASK:
1. What will happen if we input x(n)={0,0,1,0,0} into the above system
The code will be same as above, there is only change in the value of x(n).
Thoughts:
The input signal x(n)= [0 0 1 0 0] is convolved with the impulse response, resulting in the output signal y(n).
The three subplots visualize the impulse response, input signal, and output signal obtained through
convolution, offering insights into the system's behavior. This representation clearly explains how the
system processes the given input signal and produces the corresponding output over time.
2. Can you prove the commutative property of the convolution?
Thoughts:
This code includes three subplots: one for each signal (f and g) and one for the convolutions (f * g and g * f).
The legend in the third subplot indicates which convolution is represented by each color. The code also checks
that convolution do hold the property of commutative.
3. Modify the code to prove Associative and Distributed properties of the convolution.
Thoughts:
The code is modified to check on the associative and distributive properties held by convolution.
4. Convolve your recorded sound with drumloop.wav. Note your observation. a) Plot the output. b) Listen to
the output.
clear all; close all; clc;
[x1, Fs1] = audioread('E:\matlab\noise.mp3');
[x2, Fs2] = audioread('E:\voice records lab task matlab dsp\asma 0.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('asma 0.wav');
grid on;
subplot(3, 1, 2)
plot(nx2, x2, 'g')
xlabel('Time index (n)');
ylabel('Amplitude');
xlim([nx1(1) - 1, nx1(end) + 1]);
title('noise.wav');
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 output
sound(z, Fs2);
% Saving the convolved audio
z1 = rescale(z);
audiowrite('E:\voice records lab task matlab dsp\asmaConvolved.wav', z1, Fs2);
Conclusion:
It performs convolution on two audio signals, 'noise.wav' and 'asma 0.wav,' by loading, adjusting channels, and creating
time vectors. It then plots the original signals and the convolved output in a 3-subplot figure, enabling a visual
comparison of their amplitudes over time. The code also plays the convolved output and saves it as
'asmaConvolved.wav.' It is crucial to ensure the existence and correct paths of the specified audio files for the code to be
executed successfully.
NED University of Engineering &
Technology Department of Electrical
Engineering
% Cross-correlation
[rxy, l] = xcorr(x, y); % Cross-correlation of x and y
[maxR, indR] = max(rxy); % Find the maximum correlation and its index
% Normalize correlation
norm_corr = rxy / max(abs(rxy));
perct_corr = norm_corr * 100;
% Plotting
figure
% Plot signal x
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
% Plot signal y
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
% Plot cross-correlation
subplot(4, 1, 3)
stem(l, rxy, 'filled', 'k')
xlabel('Lag Index (l)'), ylabel('Correlated Output')
title('Cross-Correlation')
grid
Conclusion:
The correlation at lag zero indicates how well the signals align without any time shift.
The cross-correlation operation is essential for determining how much one signal resembles another at
different points in time. The correlation peak indicates the point where the two signals are most
similar. The lag at the correlation peak represents the time shift required to align the signals for
maximum similarity.
Lab Tasks:
1. Now modify the phase of the second signal to pi/2 (it will make it cosine)and observe the correlation at
lag zero.
Changing ph2=pi/2
Result:
Conclusion:
The maximum correlation at lag = 2 indicates that the signals are most similar when y(n) is shifted two
units to the right.
This alignment maximizes the overlap between the sinusoidal and cosine waves, resulting in a peak in
the cross-correlation function.
Result:
Conclusion:
The maximum correlation at lag = 5 indicates that the signals are most similar when y(n) is shifted five
units to the right.
a lag of 5 units implies that signal y(n) is shifted five units to the right for optimal alignment with signal
x(n).
3. Check for auto-correlation (ph1 = ph2) that the lag zero value gives the m energy of the signal.
Changing ph2=0 so that ph1=ph2.
Result:
Conclusion:
Here we can observe that signal x(n) and y(n) are at perfect alignment to each other at n=25 so the
peak in the plot, corresponding to the maximum correlation occurs at lag=0.
4. Observe that the commutative property does not hold.
% Clear workspace, close figures, and clear command window
clear all;
close all;
clc;
% Generate signals x(n) and y(n)
n = [0:49]; % Time index
ph1 = 0; % Phase for signal x
ph2 = pi/2; % Phase for signal y
x = sin(2*pi*0.1*n + ph1); % Signal x
origin_x = 1;
nx = [1:length(x)] - origin_x; % Time indices for x
y = sin(2*pi*0.1*n + ph2); % Signal y
origin_y = 1;
ny = [1:length(y)] - origin_y; % Time indices for y
% Cross-correlation with order x, y
[rxy_xy, l_xy] = xcorr(x, y); % Cross-correlation of x and y
% Cross-correlation with order y, x
[rxy_yx, l_yx] = xcorr(y, x); % Cross-correlation of y and x
% Display correlation information
disp(['Correlation at lag zero for x, y: ' num2str(rxy_xy(l_xy == 0)) '.'])
disp(['Max correlation at lag for x, y: ' num2str(l_xy(rxy_xy == max(rxy_xy))) '.'])
disp(['Correlation at lag zero for y, x: ' num2str(rxy_yx(l_yx == 0)) '.'])
disp(['Max correlation at lag for y, x: ' num2str(l_yx(rxy_yx == max(rxy_yx))) '.'])
% Normalize correlation
norm_corr_xy = rxy_xy / max(abs(rxy_xy));
perct_corr_xy = norm_corr_xy * 100;
norm_corr_yx = rxy_yx / max(abs(rxy_yx));
perct_corr_yx = norm_corr_yx * 100;
% Plotting
figure
% Plot signal x
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
% Plot signal y
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
% Plot cross-correlation x, y
subplot(4, 1, 3)
stem(l_xy, rxy_xy, 'filled', 'k')
xlabel('Lag Index (l)'), ylabel('Correlated Output')
title('Cross-Correlation (x, y)')
grid
% Plot normalized cross-correlation x, y
subplot(4, 1, 4)
stem(l_xy, norm_corr_xy, 'filled', 'k')
xlabel('Lag Index (l)'), ylabel('Normalized Correlated Output')
title('Normalized Cross-Correlation (x, y)')
grid
% Plotting for y, x
figure
% Plot signal x
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
% Plot signal y
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
% Plot cross-correlation y, x
subplot(4, 1, 3)
stem(l_yx, rxy_yx, 'filled', 'k')
xlabel('Lag Index (l)'), ylabel('Correlated Output')
title('Cross-Correlation (y, x)')
grid
Result:
Conclusion:
The lag at which the maximum correlation occurs may differ between x⋆y and y⋆x, providing an
example where the commutative property does not hold.
5. Modify the code, such that the correlation is obtained using convolution command.
% Clear workspace, close figures, and clear command window
clear all;
close all;
clc;
% Normalize correlation
norm_corr_conv = rxy_conv / max(abs(rxy_conv));
perct_corr_conv = norm_corr_conv * 100;
% Plotting
figure
% Plot signal x
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
% Plot signal y
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
Result:
Conclusion:
This code uses conv to perform convolution, and the resulting cross-correlation is displayed. The convolution
is equivalent to cross-correlation with one of the signals flipped.
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.
Excel:
Result:
Matlab:
Thoughts:
The correlation between the A and B voltages indicates a strong negative correlation.
The correlation between the B and C voltages indicates a moderate positive correlation.
The correlation between the A and C voltages indicates a moderate negative correlation.
LAB 5
DIGTAL SIGNAL PROCESSING
In lab task:
Conclusion:
The code calculates and plots the magnitude and phase spectra of the 4-point Discrete Fourier Transform
(DFT) for the input signal [1, 2, 3, 0]. The magnitude spectrum (top subplot) reveals the amplitudes of different
frequency components, while the phase spectrum (bottom subplot) provides information about their
temporal alignment. The purpose of the code is to analyze the frequency domain characteristics of the signal,
gaining insights into its composition and phase relationships. This kind of analysis is essential in understanding
the frequency content of a signal.
Lab Task:
Task-1: 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 Fs=1000 samples/sec
x(n)= {0.3535, 0.3535, 0.6464, 1.0607 , 0.3535, -1.0607, -1.3535 , -0.3535}
Conclusion:
This code finds the forward DFT of the given time domain sequence and also show its magnitude and phase
waveform.
Task-2: Inverse DFT using Matrix inversion
Develop a MATLAB code to find the inverse DFT output of the following frequency domain sequence by using the iDFT
equation in matrix form (use matrix inversion).
X(k)= {0, 4∠-90 , 2∠45 , 0, 0, 0, 2∠-45 , 4∠90 }
Conclusion:
This code finds the inverse DFT output of the given frequency domain sequence and also show its magnitude
and phase waveform by matrix inversion method.
Task-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).
X(k)= {0, 4∠-90 , 2∠45 , 0, 0, 0, 2∠-45 , 4∠90 }
Conclusion:
This MATLAB code successfully computes and visualizes the inverse Discrete Fourier Transform (iDFT) of a
given frequency-domain sequence using the conjugate method. The resulting frequency-domain sequence is
displayed in both real and imaginary parts, providing a comprehensive understanding of the signal
transformation.
LAB 6
In lab Task:
Conclusion:
In this audio signal noise is included which is making the audio sound distorted. This noise can be removed by
first identifying its frequency. For this purpose, DFT is performed on this audio signal. In the first plot, we have
included the frequency range from 0 to Fs/2 (to get a general idea of what is frequency of noisy signal). Then
we have jotted down the xlim from 0 to 1000 as we get the noisy signal frequency in this range.
LAB TASK:
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.
Result:
Conclusion:
In conclusion, the analysis of the recorded audio data involved both time and frequency domain
representations. The time domain plot provided insights into the amplitude variations over time, while the
frequency domain representation, obtained through the Fourier Transform, revealed the distribution of
frequencies present in the signal. By identifying the fundamental frequency and calculating its energy, we
gained an understanding of the dominant component in the signal. Additionally, the assessment of energy in
different harmonics further characterized the spectral content of the audio. This comprehensive analysis
facilitates a thorough understanding of the recorded data in both the time and frequency domains.
Task-1: Removal of tone from the noisy signal through FFT result.
To remove the noisy tone, we can zero in on the noisy tone by looking at the DFT of the noisy signal. Take
Inverse DFT [idft] 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.
Conclusion:
This MATLAB code applies thresholding to modify an audio signal ('noisy.wav'). It uses the Discrete Fourier
Transform (DFT) to analyze frequency components. The script sets magnitudes below a specified threshold to
zero, obtaining a modified spectrum. The inverse DFT reconstructs the modified time-domain signal. Both
original and modified signals are played for auditory comparison. Plots depict the original and modified
signals, illustrating the impact of thresholding on the audio signal. Adjusting the threshold parameter
influences the extent of signal modification.
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.
Result:
Conclusion:
This MATLAB code aims to remove a tonal component from a given audio signal through a downsampling and
de-noising approach. The noisy audio signal is initially loaded and down-sampled to reduce its size, with the
down-sampled signal plotted in the first subplot. A zoomed-in view of a specific region containing the tonal
component is presented in the second subplot, allowing for the identification of its period. A sinusoidal tone
signal with the identified frequency is generated and up-sampled to match the original signal's size. The third
subplot displays the de-noised signal, obtained by subtracting the up-sampled tone signal from the original
noisy signal. This process effectively achieves the removal of the tonal component, and the user can assess the
results by comparing the original, zoomed-in, and de-noised signals both visually.
NED University of Engineering & Technology Department of
Electrical Engineering
Task 02:
Analysis of 1st order Analog system [one pole at LHS]
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.
COMMENTS:
The system with a pole at s=−0.5 is a low-pass filter, has a first-order, and is stable due to the pole being in the
left-half plane.
Task 03: 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.
COMMENTS: The given first-order system with a pole at s=0.5 is a high-pass filter, and is unstable due to
the pole being in the right-half plane.
Task 05: 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: (-0.5-
j*pi/2), (-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.
COMMENTS: The given system is a second-order band-stop (notch) filter. The system is stable, and its
frequency response exhibits characteristics of a band-stop filter.
Task 06: 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=+0.5+j*pi/2, +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 the system.
COMMENTS:
The given system is a second-order band-pass filter. The system is not stable, and its frequency response
exhibits characteristics of a band-pass filter.
Task-7: Analysis of 2nd order Analog system [complex zeros and poles at LHS]
(a) Generate pole-zero constellation of an analog system in s-plane for given roots [zeros: s=±j(π/2) & poles:
s=-0.2+j(π/4), -0.2-j(π/4)]
LAB SESSION 08
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 [ zero: z=0 & pole:
z=0.9∠0]
EXPLANATION:
The system is determined to be IIR through the ‘isfir’ function, as A is assigned the result of isfir(H), and it is
not true. Therefore, the digital system is Infinite Impulse Response (IIR) due to the presence of at least one pole.
The system is also referred to as stable because the pole lies inside the z plane.
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: z=0 & pole:
z=(0.9<pi),(0.9<-pi)]
b) Write the transfer function of a system
c) Determine whether the digital system is FIR or IIR
d) Plot corresponding frequency response and impulse response of a digital system.
EXPLANATION:
The digital system is a first-order IIR filter
with stable behavior, as indicated by its pole
location inside the unit circle. The frequency response shows its characteristics as a low-pass filter.
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: z=0 & pole:
z=1∠0 ]
EXPLANATION:
This digital system is a first-
order Infinite Impulse Response
(IIR) filter with a pole at the DC
location of the unit circle. The
system is marginally stable,
confirmed by the presence of poles at the unit circle. The frequency response depicts a gradual decrease in gain
with increasing frequency, typical of a first-order IIR low-pass filter.
Task-4: 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:[ zero: z=0 & pole:
z=1<pi,1<-pi]
EXPLANATION:
The analyzed 1st order digital
system has a pole at the Nyquist
frequency (Fs/2) of the unit circle.
The pole-zero plot illustrate a
Infinite Impulse Response (IIR)
system. The system is marginally
stable, confirmed by the pole being
located at the unit circle. The
frequency response plot
demonstrates a characteristic
response for a first-order IIR filter,
with gain decreasing as frequency
increases. Therefore, this digital
system is a stable, first-order IIR
filter with a pole at the Nyquist
frequency.
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:[ zero: z=0 & pole:
z=1.1∠0]
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:[ zero: z=0 & pole:
z=1.1<pi, 1.1<-pi]
EXPLANATION:
This digital system is a first-order
Infinite Impulse Response (IIR) filter
with a pole outside the unit circle at
Fs/2. The pole-zero plot, transfer
function, and frequency response
illustrate its first-order nature, and the
pole at Fs/2 contributes to a high-
frequency roll-off. Being an IIR filter,
the system is unstable, confirmed by
the pole location outside the unit
circle. The frequency response plot
exhibits a gradual increase in gain with frequency.
EXPLANATION:
This digital system is a 2nd
order Finite Impulse Response
(FIR) filter with poles at the
origin. The pole-zero plot and
the frequency response
confirm its 2nd-order nature.
Being an FIR filter, the system
exhibits stability, as indicated
by poles at the origin. The
frequency response plot
illustrates the characteristic
response of a 2nd order FIR
filter, with oscillatory behavior
and peaking at its resonant
frequency.
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:[ zeros: z=1<±π/2) &
poles: z=1<±π/4 ]
EXPLANATION:
This digital system is a 2nd order
Infinite Impulse Response (IIR)
filter with complex conjugate poles
at the unit circle. The pole-zero
plot, and frequency response
confirm its 2nd order nature, with
the complex poles contributing to
oscillatory behavior. Being an IIR
filter, the system is stable, evident
from the poles lying on the unit
circle. The frequency response plot
exhibits resonant peaks associated
with a 2nd order IIR filter.
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:[ zeros: z=1<±π/2) &
poles: z=1.2<±π/4]
EXPLANATION:
This digital system is a 2nd
order Infinite Impulse Response
(IIR) filter with complex
conjugate poles outside the unit
circle. The pole-zero plot and
frequency response confirm its
2nd-order nature, with the
complex poles contributing to
an oscillatory response. Being
an IIR filter, the system is
unstable, evident from the poles
located outside the unit circle.
The frequency response plot
exhibits resonant peaks and oscillations, characteristic of a 2nd order IIR filter.
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:[ zeros: z=0.8<±π/2)
& poles: z=0.8<±π/4]
EXPLANATION:
This digital system is a
2nd order Infinite
Impulse Response (IIR)
filter with complex
conjugate zeros inside the
unit circle. The pole-zero plot and frequency response confirm its 2nd-order nature, with the complex zeros
contributing to a resonant behavior. Being an IIR filter, the system is stable, evident from the zeros located
inside the unit circle. The frequency response plot exhibits peaks associated with a 2nd order IIR filter.
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 [zeros: z=1.2<±π/2) &
poles: z=0.8<±π/4]
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.
EXPLANATION:
This digital system is a 2nd order Infinite Impulse Response (IIR) filter with complex conjugate zeros outside
the unit circle. The pole-zero plot and frequency response indicate its 2nd order nature with complex zeros
contributing to resonant behavior. Being an IIR filter, the system is stable, evident from the poles located inside
the unit circle.
LAB 9
Inlab Task 1:
Conclusion:
In conclusion, this MATLAB code effectively illustrates the generation, analysis, and visualization of two
sinusoidal signals with frequencies of 500 Hz and 600 Hz. Through the use of discrete Fourier transform (DFT),
the code provides insights into the frequency content of these signals, offering both time-domain and
frequency-domain representations. The clear subplots showcase the amplitude variations over time, while the
corresponding spectra reveal prominent peaks at the specified frequencies. Overall, this code serves as a
fundamental example of signal processing and spectral analysis in MATLAB, providing a valuable foundation
for understanding and extending similar concepts in more complex scenarios.
Inlab Task 2:
Conclusion:
The MATLAB code showcases the application of a Hanning window to a sinusoidal signal with a frequency of
1050 Hz. It includes the generation of the signal and window, the visualization of their time-domain
representations, and the presentation of their respective frequency spectra. The resulting windowed signal is
displayed, highlighting the impact of windowing on mitigating spectral leakage. This concise script serves as a
practical demonstration of windowing techniques and their effects on signal processing .
Conclusion:
DFT Leakage occurs when input frequency does not align with the DFT frequency resolution.
Result:
Conclusion:
The number of cycles is not an integer, indicating potential spectral leakage. To reduce spectral leakage,
consider adjusting the parameters or using window functions.
2. Triangular
3. Hamming
4. Hann
5. Gaussian
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.
The provided code generates a sinusoidal signal with a frequency of 1050 Hz sampled at 8000
samples/second. It computes the 64-point Discrete Fourier Transform (DFT) of the signal and plots the
magnitude spectrum. The observed spectrum indicates characteristics of the DFT leakage phenomenon. Due
to a potential frequency mismatch between the signal and the DFT bins, spectral leakage occurs, leading to the
spread of energy to adjacent frequency bins. This effect is manifested as side lobes around the main peak,
resulting in a wider main lobe in the spectrum.
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.
Conclusion:
This code introduces a loop over different window functions and plots the windowed spectrum for each. You
can run this code in MATLAB and observe the impact of each window function on the signal's spectrum.
NED University of Engineering & Technology Department of
Electrical Engineering
Explanation:
The task involves designing a 16th-order IIR Butterworth bandpass filter with specified pass band and stop band
edges, adhering to stringent ripple and attenuation criteria. The resulting filter characteristics, visualized through
magnitude, phase, impulse response, and pole-zero plots, showcase its efficacy in selectively passing signals
within the defined frequency range while efficiently attenuating others.
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?
TAKING Fs= 8000Hz
DIFFERENCE EQUATION:
yn= b0 xn+b1 xn-1+b3 xn-3 / y0+a1 yn-1+a2 yn-2+a3 yn-3
EXPLANATION:
The filtered voice had a smoother and clearer quality. It seemed as though the higher-pitched elements had been
removed, resulting in a more enjoyable listening experience. No distortion was present, and overall, the filter
effectively enhanced the voice, providing a nice and smooth sound.