0% found this document useful (0 votes)
219 views11 pages

Name: Moving Average Filter Rating: Figure 1. Manual Solving of Impulse Response

This document describes an engineering lab activity on signal processing. The activity involves manually calculating impulse responses for different systems, sketching a direct form II implementation, using Octave to filter input signals with a moving average filter, and plotting the raw and filtered COVID-19 case data from Misamis Occidental to analyze trends. The student implemented the tasks, observed that the moving average filter attenuated higher frequencies and reduced noise in the COVID data, allowing clearer trends to be identified.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
219 views11 pages

Name: Moving Average Filter Rating: Figure 1. Manual Solving of Impulse Response

This document describes an engineering lab activity on signal processing. The activity involves manually calculating impulse responses for different systems, sketching a direct form II implementation, using Octave to filter input signals with a moving average filter, and plotting the raw and filtered COVID-19 case data from Misamis Occidental to analyze trends. The student implemented the tasks, observed that the moving average filter attenuated higher frequencies and reduced noise in the COVID data, allowing clearer trends to be identified.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

La Salle University

College of Engineering and Architecture

ELC415 Signals, Spectra and Signal Processing


LABORATORY

Name: LAB 05 Rating


Ron Resma Moving Average Filter

Date:
12 October 2021

PreLab Assignment
1. Manually compute the impulse response of the system described
by the difference equation 𝑦(𝑛)=13[𝑥(𝑛)+𝑥(𝑛−1)+𝑥(𝑛−2)]
The impulse response is the output y(n) if the input x(n) is a
unit sample or x(n)={0,1,0}. Call the input response h(n).

Figure 1. Manual solving of impulse


response
1
2. Repeat for y ( n )= [x ( n ) + x ( n−1 ) + x ( n−2 ) + x ( n−3 )]
4

Figure 2.Manual solving of impulse response

3. Sketch the direct form II implementation of the system defined


1
by this input-output equation. y ( n )= [ x ( n ) + x ( n−1 ) + x ( n−2 ) ]
3

Figure 3. Direct form II


implementation
I. PROBLEMS

1. Use the input signal 𝑥[𝑛] = sin(0.2𝜋𝑛) + sin⁡(0.8𝜋𝑛) to excite

the system

1
y (n)= [x (n)+ x (n−1)+ x (n−2)+ x(n−3)]
4

Plot the input and output. Write your observations.

Useful functions: conv, subplot, stem

2. Create a GNU radio flowgraph to implement a moving average


filter with M=50

Use two input signals:

S1 (frequency = 500Hz)
S2 (frequency = 10kHz)

Plot the input and output.


Did the MAV filter attenuate the signal with higher frequency?

II. COMPUTER PROGRAM OR SIMULATION MODEL


1. Octave Script for Problem 1
%*******************************************************************
%La Salle University %ECEng313 Signals, Spectra and Signal
%Processing Laboratory
%Student Name : Ron Resma
%Activity 5
%Due Date : 26 October 2021
%Written on Octave Ver 6.2.0
%*************************************************************
******

clear all;
close all;
clc;
%Description:This activity will plot the input and output
signals of the system
%[𝑛]=sin (0.2𝜋𝑛)+sin (0.8𝜋𝑛) and
%()=1/4[𝑥(𝑛)+𝑥(𝑛−1)+𝑥(𝑛−2)+𝑥(𝑛−3)]

n=1:50;
%input signal
x1=sin(0.2*pi*n);
x2=sin(0.8*pi*n);
x3=x1+x2;

%Plotting the inputs


figure(1)
subplot(1,3,1) ;
stem(x1) ;
title('x1 f=0.1')

subplot(1,3,2) ;
stem(x2) ;
title('x2 f=0.4')

subplot(1,3,3) ;
stem(x3);
title('x3= x1 + x2 f=0.1 and 0.4')

% outputs

h=[1/4 1/4 1/4 1/4]


y1=conv(x1,h);
y2=conv(x2,h);
y3=conv(x3,h);

%Plotting the outputs


figure(2)
subplot(1,3,1) ;
stem(y1);
title('y1') ;

subplot(1,3,2) ;
stem(y2);
title('y2')

subplot(1,3,3)
stem(y3)
title('y3')
2. GNU Radio Flowgraph for Problem

Figure 4. MAV Filter for input signal 1(500Hz)

Figure 5. MAV Filter for input signal 2(10kHz)


III. RESULTS
1. Simulation Result for Problem 1

Figure 6.Plot of Inputs

The figure 6 shows the plots of the inputs mainly,


x1=sin(0.2*pi*n), x2=sin(0.8*pi*n) and the third one shows the plot
of the sum of x1 and x2.

Figure 7. Plot of Outputs

Figure 7 shows the plot of the outputs by convolving each


inputs to the impulse response.
2. Simulation Result for Problem 2

Figure 8. Waveform for Signal 1 (500Hz)

Figure 9. Waveform for signal 2


IV. INTERPRETATION
1. Interpretation of Result 1

It can be observe in the graph the the outputs y1,y2 and y3 are
attenuated compared to its inputs. The output y1 was attenuated. The
amplitude was reduced from 1 to less than 0.8.Likewise, y2 the
amplitude was decreased from 1 to less than 0.3.For y3,the plot was
a bit similar to x1.The input x2 was filtered out since it was
blocked by the low pass filter because it has a higher frequency
than x1, allowing x1 to pass.

2. Interpretation of Result 2
Comapring Signal 1(Figure 8) to Signal 2(Figure 9), the output of
the signal two has greatly attenuated with higher frequency, the
amplitude was decreased from 1 to less than 0.2. MAV Filter takes M
samples of input at a time and takes the average of those to produce
a single output point.It also improved the waveform of the outputs.

Extra Credit
Look for and download the daily new covid cases in Misamis
Occidental from the last 3 months and call this x(n). Apply a 7-day
MAV filter and call the output y(n). Plot both x(n) and y(n) and
comment what information can you get from the filtered data y(n)
which you cannot easily spot from the raw data x(n).
Code:
%*******************************************************************
%La Salle University
%ECEng313 Signals, Spectra and Signal Processing Laboratory
%Student Name : Ron Resma
%Activity 5
%Due Date : 26 October 2021
%Written on Octave Ver 6.2.0
%*******************************************************************
clear all;
close all;
clc;

% Source of data :
https://datastudio.google.com/u/0/reporting/617bd18b-6c71-49eca1b1-
74276e58d570/page/8HaNB?s=kVqCOvBiBj0

%This data is from August to October 2021


array = csvread('Covid_Cases.csv'); % input x(n)
x = array(:, 1);

y = array(:, 2);

% Convolving the data of y to the impulse h


h = [1/7 1/7 1/7 1/7 1/7 1/7 1/7];

% output y(n)
y1 = conv(y,h);

%Plot
plot(x,y,y1);
legend('Cases','7-Day Moving Average')
title('Misamis Occidental COVID-19 Cases')
xlabel('August 1 - October 31')
ylabel('Covid Cases')
grid on
Observation:

Figure 10. Daily Covid cases in Misamis Occidental applied with MAV Filter

The raw data (blue line) is a bit confusing because it is hard to


determine the trend of the covid cases, on the otherhand applying
MAV filter on it (red line) produces a clearer trend of data. It can
be observed in the raw data that from August to September the daily
covid cases rises, after some time the daily covid cases decreases
up to october.

Conclusion:

MAV Filter was used to reduce random noise while retaining a


sharp step response. It is used in regulating an array of sampled
data/signalman Filter is a simple low pass filter that block high
frequencies and allowing low frequencies to pass.

In this activity it can be seen on the results, starting from


filtering discrete signal to applying MAV filter on raw data’s that
MAV filter greatly improved the given data for much better
understanding.

RATING

Criteria Score
Ability to prepare a well
written report
Ability to write a
computer code
Ability to interpret the
results correctly

You might also like