DIGITAL SIGNAL PROCESSING
DISCRETE-TIME
SYSTEMS IN THE TIME DOMAIN
MOVING AVERAGE FILTER IN MATLAB
INTRODUCTION:
A discrete-time system processes an input signal in the
time-domain to generate an output signal with more desirable properties by
applying an algorithm composed of simple operations on the input signal and its
delayed versions. The aim of this lab is to illustrate the simulation of some
simple discrete-time systems on the computer using MATLAB.
THE MOVING AVERAGE SYSTEM:
A three-point smoothing filter is considered in the problem and it
constitutes LTI FIR system. A causal
version of the three-point smoothing filter is obtained by simply delaying the
output by one sample period, resulting in the FIR filter described by
(1)
Generalizing the above equation we obtain
(2)
Which
defines a causal M-point smoothing FIR filter. The system of equation
(2) is also known as a moving average filter. We illustrate its use in
filtering high-frequency components from a signal composed of a sum of several
sinusoidal signals.
%
Simulation of an M-point Moving Average Filter
% Generate
the input signal
n = 0:100;
s1 =
cos(2*pi*0.05*n); % A low frequency sinusoid
s2 =
cos(2*pi*0.47*n); % A high frequency sinusoid
x = s1+s2;
%
Implementation of the moving average filter
M = input('Desired
length of the filter = ');
num = ones(1,M);
y =
filter(num,1,x)/M;
% Display
the input and output signals
clf;
subplot(2,2,1);
plot(n,s1);
axis([0, 100,
-2, 2]);
xlabel('Time
index n'); ylabel('Amplitude');
title('Signal
# 1');
subplot(2,2,2);
plot(n,s2);
axis([0, 100,
-2, 2]);
xlabel('Time
index n'); ylabel('Amplitude');
title('Signal
# 2');
subplot(2,2,3);
plot(n,x);
axis([0, 100,
-2, 2]);
xlabel('Time
index n'); ylabel('Amplitude');
title('Input
Signal');
subplot(2,2,4);
plot(n,y);
axis([0, 100,
-2, 2]);
xlabel('Time
index n'); ylabel('Amplitude');
title('Output
Signal');
axis;
RESULTS:
QUESTIONS
Q.1: Run the
above program for M = 2 to generate the output signal with x[n] = s1
[n] + s2 [n] as the input. Which component of the input x[n] is
suppressed by the discrete time system simulated by this program?
Q.2: Run
Program P1 for other values of filter length M, and various values of the frequencies
of the sinusoidal signals s1 [n] and s2 [n]. Comment on
your results.
COMMENTS:
Length
of filter is 5 and values of high and low frequencies are as follows:





No comments:
Post a Comment