[go: up one dir, main page]

0% found this document useful (0 votes)
12 views7 pages

DSP Lab Exp7

The document outlines an experiment to implement Infinite Impulse Response (IIR) Butterworth filters using MATLAB, covering low pass, high pass, band pass, and band stop filters. It includes the necessary theory, MATLAB code for each filter type, expected outputs, and graphs. The experiment aims to design and analyze the performance of these filters based on specified frequency and ripple parameters.

Uploaded by

me.rithvika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views7 pages

DSP Lab Exp7

The document outlines an experiment to implement Infinite Impulse Response (IIR) Butterworth filters using MATLAB, covering low pass, high pass, band pass, and band stop filters. It includes the necessary theory, MATLAB code for each filter type, expected outputs, and graphs. The experiment aims to design and analyze the performance of these filters based on specified frequency and ripple parameters.

Uploaded by

me.rithvika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Experiment: 07

DESIGN OF IIR FILTERS

Aim:
To implement Infinite Impulse Response (IIR) Butterworth filter for the following cases
(a) Low Pass filter (b) High Pass filter (c) Band Pass filter (d) Band stop filter

Apparatus: PC having MATLAB software.

Theory:
 IIR filter are of Recursive type whereby the present output sample depends on the present input,
past Input Samples and output samples.
 Types of filters are: (1) Low pass filter (2) High Pass filter (3) Band Pass filter (4) Band stop
filter
Analog Butterworth filter:
The magnitude function of the Butterworth low pass filter is given by
MATLAB Program:
1. Program for IIR Butterworth Low pass Filter
% IIR Butterworth Low pass Filter
clc;
clear all;
fp=input('Enter pass band freq :');
fs=input('Enter stop band freq :');
Fs=input('Enter Sampling frequency:');
rp=input('Enter pass band ripple:');
rs=input('Enter stop band ripple:');
wp=2*pi*fp/Fs;
ws=2*pi*fs/Fs;
% calculates mimimum order and cutoff frequency
[N,wc]=buttord(wp,ws,rp,rs);
%Calculates Numerator and denominator coefficients of low pass filter
[b,a]=butter(N,wc);
[h,w1]=freqz(b,a); % Obtains magnitude and frequency response
plot(w1/pi,20*log10(abs(h))); % plots magnitude response values
xlabel('normalized frequency');
ylabel('Magnitude in dB');
title('Frequency response of Low pass filter');
Expected Output:
Enter pass band freq :200
Enter stop band freq :800
Enter Sampling frequency:10000
Enter pass band ripple:1
Enter stop band ripple:20
Expected Graphs:

Frequency response of Low pass filter


0

-20

-40
Magnitude in dB

-60

-80

-100

-120

-140
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
normalized frequency

2. Program for IIR Butterworth High pass Filter


% IIR Butterworth High pass Filter
clc;
clear all;
fp=input('Enter pass band freq :');
fs=input('Enter stop band freq :');
Fs=input('enter Sampling frequency:');
rp=input('Enter pass band ripple:');
rs=input('Enter stop band ripple:');
wp=2*pi*fp/Fs;
ws=2*pi*fs/Fs;
% calculates mimimum order and cutoff frequency
[N,wc]=buttord(wp,ws,rp,rs);
%Calculates Numerator and denominator coefficients of High pass
filter
[b,a]=butter(N,wc,'high');
[h,w1]=freqz(b,a); % Obtains magnitude and frequency response
plot(w1/pi,20*log10(abs(h))); % plots magnitude response values
xlabel('normalized frequency');
ylabel('Magnitude in dB');
title('Frequency response of High pass filter');
Expected Output:
Enter pass band freq :200
Enter stop band freq :100
enter Sampling frequency:2000
Enter pass band ripple:1
Enter stop band ripple:20
Expected Graphs:
Frequency response of High pass filter
0

-20

-40

-60
Magnitude in dB

-80

-100

-120

-140

-160
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
normalized frequency

3. Program for IIR Butterworth Band pass Filter


% IIR Butterworth Band pass filter
clc;
clear all;
fp1=input('Enter pass band freq1:');
fp2=input('Enter pass band freq2:');
fs1=input('Enter stop band freq1 :');
fs2=input('Enter stop band freq2 :');
Fs=input('Enter sampling Frequency');
rp=input('Enter pass band ripple:');
rs=input('Enter stop band ripple:');
fp=[fp1,fp2];
fs=[fs1,fs2];
wp=2*pi*fp/Fs;
ws=2*pi*fs/Fs;
[N,wc]=buttord(wp,ws,rp,rs);
%Calculates Numerator and denominator coefficients of Band pass filter
[b,a]=butter(N,wc);
[h,w1]=freqz(b,a);
plot(w1/pi,20*log10(h));
xlabel('normalized frequency');
ylabel('Magnitude in Db');
title('Frequency response of Band pass filter');
Expected Output:
Enter pass band freq1:400
Enter pass band freq2:600
Enter stop band freq1 :200
Enter stop band freq2 :800
Enter sampling Frequency10000
Enter pass band ripple:1
Enter stop band ripple:20

Expected Graphs:

Frequency response of Band pass filter


0

-20

-40

-60
Magnitude in Db

-80

-100

-120

-140

-160

-180
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
normalized frequency

4. Program for IIR Butterworth Band stop filter


% IIR Butterworth Band stop filter
clc;
clear all;
fp1=input('Enter pass band freq1:');
fp2=input('Enter pass band freq2:');
fs1=input('Enter stop band freq1 :');
fs2=input('Enter stop band freq2 :');
Fs=input('Enter sampling Frequency:');
rp=input('Enter pass band ripple:');
rs=input('Enter stop band ripple:');
fp=[fp1,fp2];
fs=[fs1,fs2];
wp=2*pi*fp/Fs;
ws=2*pi*fs/Fs;
[N,wc]=buttord(wp,ws,rp,rs)
%Calculates Numerator and denominator coefficients of Band stop filter
[b,a]=butter(N,wc,'stop');
[h,w1]=freqz(b,a);
DSP Lab

plot(w1/pi,20*log10(h));
xlabel('normalized frequency');
ylabel('Magnitude in Db');
title('Frequency response of Band stop filter');
Expected Output:
Enter pass band freq1:400
Enter pass band freq2:600
Enter stop band freq1 :200
Enter stop band freq2 :800
Enter sampling Frequency:10000
Enter pass band ripple:1
Enter stop band ripple:20
Expected Graphs:
Frequency response of Band stop filter
0

-20

-40
Magnitude in Db

-60

-80

-100

-120

-140
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
normalized frequency

Result:
Butterworth analog low pass, High pass, Band pass and Band stop IIR filters are implemented using MATLAB.

Exercise:
1. Design an Analog Butterworth filter that has -1dB pass band attenuation at a frequency of 200
rad/sec and at least -20dB stop band attenuation at 800 rad/sec.

You might also like