494 C H A P T E R 8: Discrete-Time Signals and Systems
FIGURE 8.11
First-order
autoregressive filter
impulse responseh[n]
and responsey[n]due
tox[n]=u[n]−
u[n−3].0 5 10 15 2000.51h[n]nn0 2 4 6 8 10 1200.511.52y
[n
]%%%%%%%%%%%%%%%%%%%%%
% Example 8.24
%%%%%%%%%%%%%%%%%%%%%
a = [1−0.5]; b = 1; % coefficients of the difference equation
d = [1 zeros(1, 99)]; % approximate delta function
h = filter(b, a, d); % impulse response
x = [ones(1, 3) zeros(1, 10)]; % input
y = filter(b, a, x); % output from filter function
y1 = conv(h, x); y1 = y1(1:length(y)) % output from conv
n8.3.4 Linear and Nonlinear Filtering with MATLAB..............................
One is not always able to get rid of undesirable components of a signal by means of linear filtering.
In this section we will illustrate the possible advantages of using nonlinear filters.Linear Filtering
To illustrate the way a linear filter works, consider getting rid of a random disturbanceη[n], which we
model as Gaussian noise (this is one of the possible noise signals MATLAB provides) that has been
added to a sinusoidx[n]=cos(πn/ 16 ). Lety[n]=x[n]+η[n]. We will use an averaging filter having
an input–output equationz[n]=1
M
M∑− 1
k= 0y[n−k]