Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

INSTITUTE OF BIOMEDICAL ENGINEERING & TECHNOLOGY

LIAQUAT UNIVERSITY OF MEDICAL & HEALTH SCIENCES


JAMSHORO

Subject: Signal and System Year: 3rd, Semester5th

LAB HANDOUT- 12

Name: _________________________________ Roll No: ____________________

Score: __________ Signature of Tutor: ______________ Date:________________

To design Types of an IIR Filter

REQUIRED:
PC with Matlab

INTRODUCTION:

IIR filters are one of two primary types of digital filters used in Signal Processing applications
(the other type being FIR). “IIR” means “Infinite Impulse Response.”

The advantage of IIR filters over FIR filters is that IIR filters usually require fewer coefficients
to execute similar filtering operations, that IIR filters work faster, and require less memory
space. ... FIR filters are better suited for applications that require a linear phase response.

IIR filters can achieve a given filtering characteristic using less memory and calculations than a
similar FIR filter.

The primary advantage of IIR filters over FIR filters is that they typically meet a given set of
specifications with a much lower filter order than a corresponding FIR filter.

DESCRIPTION:

Matlab contains various routines for design and analyzing digital filter IIR. Most of these are part
of the signal processing tool box. A selection of these filters is listed below.
 Buttord (for calculating the order of filter)
 Butter (creates an IIR filter)
 Ellipord (for calculating the order of filter)
 Ellip (creates an IIR filter)
 Cheb lord (for calculating the order of filter)
 Cheyb1 (creates an IIR filter)

DESIGNING IIR FILTERS TO FREQUENCY DOMAIN SPECIFICATION:


 This toolbox provides order selection functions that calculate the minimum filter order
that meets a given set of requirements.

FILTER TYPE ORDER ESTIMATION FUNCTION


Butterworth [N, Wn]= buttord (Wp,Ws,Rp,Rs)
[B,A]=butter(N,Wn)
Chebyshev type I [N, Wn]= cheblord (Wp,Ws,Rp,Rs)
[B,A]=cheby1(N,Wn)

Chebyshev type II [n,Wn]=cheb2ord (Wp,Ws,Rp,Rs)

Elliptic [N, Wn]= ellipord (Wp,Ws,Rp,Rs)


[B,A]=ellip(N,Wn)

In the Filter Design & Analysis Tool dialog box, set the following filter options:

Option Values
Response Type Highpass
Design Method IIR Butterworth
Filter Order Specify order: 5
Units: Hz
Fs: 48000
Frequency Specifications
Fc: 10800

INLAB-TASK:

Design an IIR Butterworth filter, with pass band Edge is at 0.4 and 0.65, stop band edge at 0.3
and 0.75, Pass band Ripple is 1db stop band ripple is 40db show magnitude and Phase response.

PROCEDURE:

In order to design a filter, we have to use filter design and analysis tool in matlab. To open filter
design and analysis tool write “fdatool” in command Window
filter design and analysis tool window will appear on the screen.

Then according to given in Lab task, we have to select an IIR butterworth and select Band
Pass in Response type
Then in Frequency specifications, Set Units to the normalized (0 to 1), wstop1: 0.3, wpass1:
0.4, wpass2: 0.65, wstop2: 0.75.

Now in Magnitude specifications, set Unit to dB, Astop1: 40 Apass: 1 Astop2: 80

After setting the entire values now click on Design Filter at bottom of the window

You’ll have the Magnitude


Then click on the Phase response it’ll show the phase of the designed filter.

Example 1 : Code for designing Buttord and Butter Filter:


CODE:

fs=4000;
[n,w]=buttord(1000/2000,1200/4000,1,50);
[b,a]=butter(n,w);
figure(1)
freqz(b,a,512,fs);
figure(2)
[h,q]=freqz(b,a,512,fs);
plot(q,abs(h));
grid

OUTPUT:
1.4

1.2

0.8

0.6

0.4

0.2

0
0 200 400 600 800 1000 1200 1400 1600 1800 2000
M a g n it u d e (d B )

-100

-200

-300

-400
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Frequency (Hz)
P h a s e (d e g re e s )

-200

-400

-600

-800

-1000
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Frequency (Hz)

JUST TO UNDERSTAND:
INCREASE THE RIPPLE FACTOR AND SEE THE CHANGES IN THE RESPONSES:

CODE:

fs=4000;
[n,w]=buttord(1000/2000,1200/4000,1,500);
[b,a]=butter(n,w);
figure(1)
freqz(b,a,512,fs);
figure(2)
[h,q]=freqz(b,a,512,fs);
plot(q,abs(h));
grid
100

0
Magnitude (dB)

-100

-200

-300

-400
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Frequency (Hz)

0
Phase (degrees)

-2000

-4000

-6000

-8000
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Frequency (Hz)

1.a Design IIR Band Pass Filter and Band stop Filter (Butterworth)
1.b Design IIR High Pass Filter

POST LAB TASK:

1. Write the code for Elliptic along with its order, paste its output.
2. Write the code for ChebyShev filter along its order, paste its ouput.

Note: Perform the given post lab task with respect to low, high, passband and stop filter

You might also like