You are on page 1of 7

Digital Signal Processing

EE-414
Lab Report no.3
Fall 2022
Obtained Marks
Total Marks

Lab Engineer Signature &


Comments

Students Name
1 Muhammad Uzair Arshad
.
2 Anas Zohrab
.
3 Huzaifah Ibrahim
.

Section: A (Electronics) Group: 03


Experiment No: 03 Date of Submission:
October-14-2022
Experiment Title:
MOVING AVERAGE FILTER AND CONVOLUTION
Batch: Teacher:
BSEE 2019-23 Dr. Sufi Tabassum Gul
Semester Lab Engineer:
7th Ms. Arhama Riaz
2 Lab 3 : MOVING AVERAGE FILTER AND CONVOLUTION

3.1. Objectives:
1. To plot a discrete time real exponential.
2. To generate and plot a discrete sequence and discrete random noise.
3. To smooth a noisy sequence by the application of a moving average filter.
4. To convolve two discrete time sequences and plot the output sequence.

3.2. MATLABDepartment
Functions: of Electrical Engineering
1. rand, filter, conv
2. subplot, stem, legend
3.3. Tasks:
3.3.1. Task 1:
1. Code:
n=1:1:100;
x = 5*(0.9.^n);
stem(n, x);
2. Result:

3.3.2. Task 2:
1. Code:
N = 100;
n = 1:1:N;
y = zeros(1, N);
y(n>0 & n<11) = 1;
stem(n, y);
3 Lab 3 : MOVING AVERAGE FILTER AND CONVOLUTION

2. Result:

3.3.3. Task 3:
1. Code:
N = 100;
n = 1:1:N;
x = 5*(0.9.^n);
y = zeros(1, N);
y(n>0 & n<11) = 1;
z = conv(x, y);
subplot(3,1,1);
stem(x);
title("x[n]");
subplot(3,1,2);
stem(y);
title("y[n]");
subplot(3,1,3);
stem(z);
title("z[n] = conv(x, y)");
4 Lab 3 : MOVING AVERAGE FILTER AND CONVOLUTION

2. Results:

3.3.4. Task 4:
1. Code:
N = 100;
n = 1:1:N;
s = 2.*n.*0.9.*(0.9.^n);
noise = rand(1, N);
y = s+noise;
subplot(3,2,1);
stem(s);
title("Orignal signal");
subplot(3,2,3);
stem(noise);
title("Noise signal");
subplot(3,2,5);
stem(y);
title("Corrupted Sigbal");
subplot(3,2,2);
stem(n, abs(fft(s,N)));
title("FFt of Orignal signal");
subplot(3,2,4);
stem(n, abs(fft(noise,N)));
5 Lab 3 : MOVING AVERAGE FILTER AND CONVOLUTION

title("FFt of Noise signal");


subplot(3,2,6);
stem(n, abs(fft(y,N)));
title("FFt of Corrupted Sigbnal");
2. Results:

3.3.5. Task 5:
1. Code:
win = 10;
f = filter(ones(1, win)/win, 1, y);
hold on
stem(n,f,"filled");
stem(n,y,":diamondr");
stem(n, s);
legend("Filtered Signal", "Noisy Signal", "Original Signal");
hold off
6 Lab 3 : MOVING AVERAGE FILTER AND CONVOLUTION

2. Result:

3.3.6. Task 6:
1. Code:
figure
hold on
stem(n, abs(fft(s)),":diamondr");
stem( n ,abs(fft(f)),"filled");
legend("FFt of Original", "FFt of Filtered");
hold off
2. Result:
7 Lab 3 : MOVING AVERAGE FILTER AND CONVOLUTION

3.4. Discussion:
This lab was about signal manipulation involving convolution and moving average filter. The
convolution of two signals/vectors, u and v, represents the area of overlap under the points as v slides
across u. Algebraically, convolution is the same operation as multiplying the two vectors or signals in
Laplace domain. A moving-average filter is a common method used for smoothing noisy data. A moving-
average filter slides a window of length window size (w) along the data, computing averages of the data
contained in each window. In task 1 and 2 two discrete time sequences were generated in task 3 convolution
was performed between two signals. In task 4 a sequence was corrupted with a noise generated by using
rand() command to generate random sequence. In task 5 a moving average filter was implemented to filter
the noise from corrupted signal. In task 6 FFt of original and filtered signal were compared.
3.5. Conclusion:
This lab helped us know how to manipulate different discrete time signals and to there frequency plot to
better know the difference between original and manipulated signals. Three main MATLAB functions were
used i.e., rand (for random sequence generation), conv (for convoluting two signals) and filter (to design a
moving average filter by give the transfer function of the filter to the function filter()).

You might also like