E71 Lab 3 - The moving average filter.

Your task this week is to examine a simple moving average filter.

Consider first a three point moving average filter, implemented non-recursively:

This filter can be represented in the standard form for our difference equations as:

where b0=b1=b2=1/3, a0=1 (a0 multiplies y(n) and is not normally shown because it is assumed to be equal to one).

There are several ways to implement this in Matlab.  Try them all to show they yield identical results.

Start by defining filter coefficients and b and a matrices.

>> b=[1/3 1/3 1/3];
>> a=[1 0 0];
>> x=[0 0 0 0 1 1 1 1 1 0 0 0 0];

Filter Method 1

>> y=conv(b,x);
>> stem(y);

Filter Method 2

>> y=filter(b,a,x);
>> stem(y);

Filter Method 3

>> H=tf(b,a,1)	%Leave off ";" to display "H"
>> y=lsim(H,x);
>> stem(y);

Filter Method 4

>> H=tf(b,a,1,'variable','z^-1')	%Leave off ";" to display "H"
>> y=lsim(H,x);
>> stem(y);

Task 1:

Explain the four filter methods.  Which could not be used for an IIR (or recursive) filter?

Task 2:

Consider the signal:

Task 3: