0% found this document useful (0 votes)
18 views6 pages

DSP Exp - 5

Uploaded by

pyarlachiru
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)
18 views6 pages

DSP Exp - 5

Uploaded by

pyarlachiru
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/ 6

Roll No: 160122735011 Date: /09/24

Experiment -5

Designing IIR Filter Using Butterworth and Chebyshev


Q) Design IIR Filter with the following specifications pass band attenuation is 1 dB, stopband
attenuation is 40db, pass band edge frequency is 200hz, stop band edge frequency is 250hz and
sampling frequency is 1000hz using MATLAB.

LOW PASS FILTER:

clc;
close all;
clear all;
rp=input('Enter pass band attenuation:');
rs=input('Enter stop band attenuation:');
wp=input("Enter pass band edge frequency :");
ws=input("Enter stop band edge frequency:");
fs=input('Enter sampling frequency :');
w1=2*wp/fs;
w2=2*ws/fs;
[n1,wn1]=buttord(w1,w2,rp,rs);
[b1,a1]=butter(n1,wn1);
[n2,wn2]=cheb1ord(w1,w2,rp,rs);
[b2,a2]=cheby1(n2,rp,wn2);
[n3,wn3]=cheb2ord(w1,w2,rp,rs);
[b3,a3]=cheby2(n3,rs,wn3);
w=0:0.01:pi;
[h1 om1]=freqz(b1,a1,w);m1=20*log10(abs(h1));an1=angle(h1);
[h2 om2]=freqz(b2,a2,w);m2=20*log10(abs(h2));an1=angle(h2);
[h3 om3]=freqz(b3,a3,w);m3=20*log10(abs(h3));an1=angle(h3);
plot(om1/pi,m1,"--",om2/pi,m2,':',om3/pi,m3,"-.",'linewidth',2);
grid
legend('Butter worth','Chebyshev type1','Chebyshev type 2');
ylabel('Gain in db');
xlabel('Normalized frequency');
title('IIR Low pass filter');
axis([0 1 -50 5]);

OUTPUT:
Enter pass band attenuation: 1
Enter stop band attenuation: 40
Enter pass band edge frequency: 200
Enter stop band edge frequency: 250
Enter sampling frequency: 1000

Page No: …………………… Signature of the Faculty: ………………………..


Roll No: 160122735011 Date: /09/24

HIGH PASS FILTER:

clc;
close all;
clear all;
rp=input('Enter pass band attenuation:');
rs=input('Enter stop band attenuation:');
wp=input("Enter pass band edge frequency :");
ws=input("Enter stop band edge frequency:");
fs=input('Enter sampling frequency :');
w1=2*wp/fs;
w2=2*ws/fs;
[n1,wn1]=buttord(w1,w2,rp,rs);
[b1,a1]=butter(n1,wn1,'high');
[n2,wn2]=cheb1ord(w1,w2,rp,rs);
[b2,a2]=cheby1(n2,rp,wn2,"high");
[n3,wn3]=cheb2ord(w1,w2,rp,rs);
[b3,a3]=cheby2(n3,rs,wn3,"high");
w=0:0.01:pi;
[h1 om1]=freqz(b1,a1,w);m1=20*log10(abs(h1));an1=angle(h1);
[h2 om2]=freqz(b2,a2,w);m2=20*log10(abs(h2));an1=angle(h2);
[h3 om3]=freqz(b3,a3,w);m3=20*log10(abs(h3));an1=angle(h3);
plot(om1/pi,m1,"--",om2/pi,m2,':',om3/pi,m3,"-.",'linewidth',2);

Page No: …………………… Signature of the Faculty: ………………………..


Roll No: 160122735011 Date: /09/24

grid
legend('Butter worth','Chebyshev type1','Chebyshev type 2');
ylabel('Gain in db');
xlabel('Normalized frequency');
title('IIR High pass filter');
axis([0 1 -50 5]);

OUTPUT:
Enter pass band attenuation: 1

Enter stop band attenuation: 40

Enter pass band edge frequency: 200

Enter stop band edge frequency: 250

Enter sampling frequency: 1000

Page No: …………………… Signature of the Faculty: ………………………..


Roll No: 160122735011 Date: /09/24

BAND PASS FILTER:

clc;
close all;
clear all;
rp=input('Enter pass band attenuation:');
rs=input('Enter stop band attenuation:');
wp=input("Enter pass band edge frequency :");
ws=input("Enter stop band edge frequency:");
fs=input('Enter sampling frequency :');
w1=2*wp/fs;
w2=2*ws/fs;
[n1,wn1]=buttord(w1,w2,rp,rs);
[b1,a1]=butter(n1,wn1,'bandpass');
[n2,wn2]=cheb1ord(w1,w2,rp,rs);
[b2,a2]=cheby1(n2,rp,wn2,"bandpass");
[n3,wn3]=cheb2ord(w1,w2,rp,rs);
[b3,a3]=cheby2(n3,rs,wn3,"bandpass");
w=0:0.01:pi;
[h1 om1]=freqz(b1,a1,w);m1=20*log10(abs(h1));an1=angle(h1);
[h2 om2]=freqz(b2,a2,w);m2=20*log10(abs(h2));an1=angle(h2);
[h3 om3]=freqz(b3,a3,w);m3=20*log10(abs(h3));an1=angle(h3);
plot(om1/pi,m1,"--",om2/pi,m2,':',om3/pi,m3,"-.",'linewidth',2);
grid
legend('Butter worth','Chebyshev type1','Chebyshev type 2');
ylabel('Gain in db');
xlabel('Normalized frequency');
title('IIR bandpass filter');
axis([0 1 -50 5]);

OUTPUT:

Enter pass band attenuation: 1

Enter stop band attenuation: 40

Enter pass band edge frequency: [200 300]

Enter stop band edge frequency: [150 350]

Enter sampling frequency: 1000

Page No: …………………… Signature of the Faculty: ………………………..


Roll No: 160122735011 Date: /09/24

BAND STOP FILTER:

clc;
close all;
clear all;
rp=input('Enter pass band attenuation:');
rs=input('Enter stop band attenuation:');
wp=input("Enter pass band edge frequency :");
ws=input("Enter stop band edge frequency:");
fs=input('Enter sampling frequency :');
w1=2*wp/fs;
w2=2*ws/fs;
[n1,wn1]=buttord(w1,w2,rp,rs);
[b1,a1]=butter(n1,wn1,'stop');
[n2,wn2]=cheb1ord(w1,w2,rp,rs);
[b2,a2]=cheby1(n2,rp,wn2,"stop");
[n3,wn3]=cheb2ord(w1,w2,rp,rs);
[b3,a3]=cheby2(n3,rs,wn3,"stop");
w=0:0.01:pi;
[h1 om1]=freqz(b1,a1,w);m1=20*log10(abs(h1));an1=angle(h1);
[h2 om2]=freqz(b2,a2,w);m2=20*log10(abs(h2));an1=angle(h2);
[h3 om3]=freqz(b3,a3,w);m3=20*log10(abs(h3));an1=angle(h3);
plot(om1/pi,m1,"--",om2/pi,m2,':',om3/pi,m3,"-.",'linewidth',2);
grid
legend('Butter worth','Chebyshev type1','Chebyshev type 2');

Page No: …………………… Signature of the Faculty: ………………………..


Roll No: 160122735011 Date: /09/24

ylabel('Gain in db');
xlabel('Normalized frequency');
title('IIR bandpass filter');
axis([0 1 -50 5]);

OUTPUT:
Enter pass band attenuation: 1
Enter stop band attenuation: 40
Enter pass band edge frequency: [200 300]
Enter stop band edge frequency: [150 350]
Enter sampling frequency: 1000

RESULT:

Page No: …………………… Signature of the Faculty: ………………………..

You might also like