EE422Signals and Systems Laboratory
Infinite Impulse Response (IIR) filters
Kevin D. DonohueElectrical and Computer Engineering
University of Kentucky
FiltersFilter are designed based on specifications given by:spectral magnitude emphasisdelay and phase properties through the group delay and
phase spectrumimplementation and computational structures
Matlab functions for filter design(IIR) besself, butter, cheby1, cheby2, ellip, prony, stmcb(FIR) fir1, fir2, kaiserord, firls, firpm, firpmord, fircls,
fircls1, cremez(Implementation) filter, filtfilt, dfilt(Analysis) freqz, fdatool, sptool
Filter SpecificationsExample:Low-pass filter frequency response
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
Normalize Frequency (fs/2 = 1)
Am
plitu
de S
cale
Passband
Transitionband
Stopband
Cutoff Frequency
Ripple
Filter SpecificationsExample Low-pass filter frequency response (in dB)
0 0.2 0.4 0.6 0.8 1-70
-60
-50
-40
-30
-20
-10
0
10
Normalized Frequency (fs/2 = 1)
Sca
le in
dB Passband
Transitionband
Stopband
Cutoff Frequency
Ripple
Filter SpecificationsExample Low-pass filter frequency response (in dB) with ripple in both bands
0 0.2 0.4 0.6 0.8 1-50
-40
-30
-20
-10
0
Normalize Hz
dB
Filter Magnitude Response
Passband Ripple
Stopband Ripple
Transition
Difference Equation and TF Examples
• Derive the TFs for the following difference equations (y[n] is output and x[n] is input). (Hint: Use delay property of ZT and assume zero for initial conditions).
Show
Does this represent an FIR or IIR filter? What are the poles and zeros of this system?
Difference Equation and TF Examples
• Derive the TFs for the following difference equations (y[n] is output and x[n] is input). (Hint: Use delay property of ZT and assume zero for initial conditions).
Show
Does this represent an FIR or IIR filter? What are the poles and zeros of this system?
Difference Equation and TF Examples
• Derive the difference equation from the following TF (y[n] is output and x[n] is input). (Hint: Express in terms of negative z powers, use delay property of ZT and assume zero for initial conditions).
• Show
Is it stable? How would this be represented as direct form filter in Matlab?
Filter Specification Functions
The transfer function magnitude or magnitude response:
The transfer function phase or phase response:
The group delay (envelope delay) :
)2exp()H()(H
fjzM zf
)2exp()H()(H
fjzP zf
dffdf P
P)(H)(G
Filter Analysis Example
Consider a filter with transfer function:
Compute and plot the magnitude response, phase response, and group delay. Note pole-zero diagram. What would be expected for the magnitude response?
21
1
81.02728.11)(ˆ
zzzzH
-1.5 -1 -0.5 0 0.5 1 1.5-1.5
-1
-0.5
0
0.5
1
1.5
RE
Z-PlaneIM
Filter Analysis Example
% Script to illustrate frequency analysis of filters% given y[n] = x[n-1] + 1.2728y[n-1] - 0.81y[n-2]fs = 8000; % Sampling frequency% Numerator and denominator polynomials to represent filterb = [0, 1]; % (numerator) first is element time of current outputa = [1, -1.2728, 0.81]; % (denominator) first element is time of current output
]1[]2[81.0]1[2728.1][81.02728.11
)(ˆ21
1
nxnynynyzz
zzH
Filter Analysis Example% Frequency response[h,f] = freqz(b,a,1024,fs);figure% Magnitudeplot(f,abs(h)); xlabel('Hz'); ylabel('TF Magnitude');figure% Phaseplot(f,phase(h)); xlabel('Hz'); ylabel('TF Phase in Radians');% Group delay[d,f] = grpdelay(b,a,1024,fs);figure% delay in secondsplot(f,d/fs); xlabel('Hz'); ylabel('delay in seconds');figure% delay in samplesplot(f,d); xlabel('Hz'); ylabel('delay in samples');
Filter Analysis Example
0 1000 2000 3000 4000 5000 6000 7000 80000
2
4
6
8
Hz
TF M
agni
tude
Magnitude Response with FREQZ
0 1000 2000 3000 4000 5000 6000 7000 8000-4
-3
-2
-1
0
Hz
TF P
hase
in R
adia
ns
Phase Response with FREQZ
0 1000 2000 3000 4000 5000 6000 7000 80000
5
10
Hz
Del
ay in
Sam
ples
Group Delay with GRPDELAY
0 500 1000 1500 2000 2500 3000 3500 40000
0.2
0.4
0.6
0.8
1
1.2x 10
-3
Hz
dela
y in
sec
onds
Group Delay
Filter Design ExamplesThe following commands generate filter coefficients for basic low-pass, high-pass, band-pass, band-stop filters:For linear phase FIR filters: fir1For non-linear phase IIR filter: besself, butter, cheby1, cheby2, ellip
Example: With function fir1, design an FIR high-pass filter for signal sampled at 8 kHz with cutoff at 500 Hz. Use order 10 and order 50 and compare phase and magnitude spectra with freqz command. Use grpdelay to examine delay properties of the filter. Also use command filter to filter a frequency swept signal from 20 to 2000 Hz over 4 seconds with unit amplitude.
Filter Design ExamplesExample: With function cheby2 design an IIR Chebyshev
Type II high-pass filter for signal sampled at 8 kHz with cutoff at 500 Hz, and stopband ripple of 30 dB down. Use order 5 and order 10 for comparing phase and magnitude spectra with freqz command. Use grpdelay to examine delay characteristics. Also use command filter to filter a frequency swept signal from 20 to 2000 Hz over 2 seconds with unit amplitude.
Example: With function butter, design an IIR Butterworth band-pass filter for signal sampled at 20 MHz with a sharp passband from 3.5 MHz to 9MHz. Use order 5 and verify design of phase and magnitude spectra with freqz command.
Computational Diagrams
x[n] w[n] y[n]
z-1
z-1
b2
b1
b0
-a1
z-1
z-1
G0
-a2
1/a0
For Direct form I filter below, derive difference equation and TF
Hint: Form difference equations around accumulator/registeroutputs, convert to TF and try to cancel out auxiliary variables.
Computational DiagramsFor Direct form II filter below, derive difference equation and TF
Hint: Form difference equations around accumulator/registeroutputs, convert to TF and try to cancel out auxiliary variables.
x[n] w[n] y[n]
b2
b1
b0
z-1
z-1
-a2
-a1
G0 1/a0