DSP Exp - 5
DSP Exp - 5
Experiment -5
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
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);
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
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:
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');
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: