and h(n) are finite causal sequences, MATLAB has a function called conv(a,b)that
computes the convolution between vectors a and b. For example,
xn [1, 3, 5, 7, 9]; hn [2, 4, 6, 8, 10];
yn conv(xn,hn)
yn 2 10 28 60 110 148 160 142 90
B.3 DSP Applications
As discussed in Chapter 3, the differential equation of an IIR system can be expressed
as
yn b
0
xn b
1
xn À 1 Á Á Á b
LÀ1
xn À L 1 À a
1
yn À 1
À Á Á Á À a
M
yn À M
X
LÀ1
l0
b
l
xn À l À
X
M
m1
a
m
yn À m:
B:5
As discussed in Chapter 4, the transfer function of this IIR filter can be expressed as
Hz
P
LÀ1
l0
b
l
z
Àl
P
M
m0
a
m
z
Àm
,
B:6
where a
0
1. The MATLAB function
y filter(b, a, xn);
performs filter operation to the data in vector xn that contains signal x(n) with a filter
described by the vector b that contains the coefficients b
l
and the vector a that contains
the coefficients a
m
, producing the filter result y. For example, the difference equation of
an IIR filter is given as
yn 0:0305xn À 0:0305xn À 2 1:5695yn À 1 À 0:9391yn À 2,
the MATLAB script (figb3.m in the software package) to compute the filter output
yn with input sequence xn is given as follows:
n [0:139];
x1n 1.5*sin(2*pi*100*n*0.001+0.25*pi);
x2n 1.2*randn(1,140);
xn x1n+x2n;
b [0.0305, 0 À0.0305];
a [1, À 1.5695, 0.9391];
yn filter(b,a,xn);
plot(n,xn,`:', n,yn,`À');
DSP APPLICATIONS
463