<< Chapter < Page | Chapter >> Page > |
The general form of an IIR filter is
which can be rewritten more concisely as
where
are column vectors of the parameters of the filter and where
are vectors of past input and output data.
The symbol
${z}^{T}$ indicates the transpose of the vector
$z$ .
In M
atlab , transpose is represented using the single apostrophe
'
, but take care: when using complex numbers,
the apostrophe actually implements a complex conjugateas well as transpose.
M
atlab has a number of functions that make it easy to
explore IIR filtering.For example, the function
impz
plots the impulse
response of a discrete IIR (or FIR) filter.The impulse response of the system
[link] is found by entering
b=1;
a=[1, -0.8];
impz(b,a)
The parameters are the vectors
b=
$[{b}_{0},{b}_{1},...,{b}_{m}]$ and
a=
$[1,-{a}_{0},-{a}_{1},...,-{a}_{n}]$ .
Hence the above code gives the responsewhen
$a$ of
[link] is
$+0.8$ .
Similarly, the command
freqz(b,a)
displays the
frequency response for the IIR filter where
b
and
a
are constructed in the same way.
The routine
waystofiltIIR.m
explores ways of implementing IIR filters.
The simplest method uses the
filter
command.
For instance
filter(b,a,d)
filters the
data
d
through the IIR system with parameters
b
and
a
defined as above. This gives the same output as first
calculating the impulse response
h
and then using
filter(h,1,d)
. The fastest (and most general) way to implement the
filter is in the
for
loop at the end, which mimics the time domain
method for FIR filters, but includes the additionalparameters
a
.
a=[1 -0.8]; lena=length(a)-1; % autoregressive coefficientsb=[1]; lenb=length(b); % moving average coefficientsd=randn(1,20); % data to filter
if lena>=lenb, % dimpulse requires lena>=lenb
h=impz(b,a); % impulse response of filter yfilt=filter(h,1,d) % filter x[k] with h[k]end
yfilt2=filter(b,a,d) % filter directly using a and by=zeros(lena,1); x=zeros(lenb,1); % initial states in filter
for k=1:length(d)-lenb % time domain method x=[d(k);x(1:lenb-1)]; % past values of inputs ytim(k)=-a(2:lena+1)*y+b*x; % directly calculate y[k]
y=[ytim(k);y(1:lena-1)]; % past values of outputs
end
waystofiltIIR.m
ways to implement IIR filters
(download file)
Like FIR filters, IIR filters can be lowpass, bandpass, highpass, or can have almost any imaginableeffect on the spectrum of its input.
Some IIR filters can be used as inverses to some FIR filters. Show that the FIR filter
is an inverse of the IIR filter [link] .
FIR filters can be used to approximate the behavior of IIR filters by truncating the impulse response.Create a FIR filter with impulse response given by the first 10 terms of [link] for $a=0.9$ and $b=2$ . Simulate the FIR filter and the IIRfilter [link] in M atlab , using the same random input to both. Verify that the outputsare (approximately) the same.
Notification Switch
Would you like to follow the 'Software receiver design' conversation and receive update notifications?