Exp 8
Exp 8
AIM: Design following IIR Digital Filters using i) Butterworth and ii) Chebyshev designs:
1. Butterworth
a. LPF
PROGRAM:
clc;
clear all;
rp=input('enter passband ripple');
rs=input('enter stopband ripple');
wp=input('enter passband frequency');
ws=input('enter stopband frequency');
fs=input('enter sampling frequency');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn);
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
ylabel('gainin db');grid;
xlabel('normalised frequency');
subplot(2,1,2);
plot(om/pi,an);
ylabel('phase in radians');grid;
xlabel('normalisedfrequency');
b.HPF
PROGRAM:
clc;
clear all;
rp=input('enter passband ripple');
rs=input('enter stopband ripple');
wp=input('enter passband frequency');
ws=input('enter stopband frequency');
fs=input('enter sampling frequency');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn,'high');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
ylabel('gain in db');grid;
xlabel('normalised frequency');
subplot(2,1,2);
plot(om/pi,an);
ylabel('phase in radians');grid;
xlabel('normalisedfrequency');
c.BPF
PROGRAM:
clc;
close all;
clear all;
alphap=2;
alphas=20;
ws=[0.1,0.5];
wp=[0.2,0.4];
[n,wn]=buttord(wp,ws,alphap,alphas);
[b,a]=butter(n,wn);
w=0:0.01:pi;
[h,ph]=freqz(b,a,w);
m=20*log(abs(h));
an=angle(h);
subplot(2,1,1);plot(ph/pi,m);grid;
ylabel('Gain in dB');xlabel('normalised frequency')
title('Magnitude response of Butterworth Band Pass Filter');
subplot(2,1,2);plot(ph/pi,an);grid;
ylabel('Phase in radians');xlabel('normalised frequency')
title('Phase response of Butterworth Band Pass Filter');
d. BSF
PROGRAM:
clc;
close all;
clear all;
alphap=2;
alphas=20;
ws=[0.2,0.4];
wp=[0.1,0.5];
[n,wn]=buttord(wp,ws,alphap,alphas);
[b,a]=butter(n,wn,'stop');
w=0:0.01:pi;
[h,ph]=freqz(b,a,w);
m=20*log(abs(h));
an=angle(h);
subplot(2,1,1);plot(ph/pi,m);grid;
ylabel('Gain in dB');xlabel('normalised frequency')
title('Magnitude response of Butterworth Band Reject Filter');
subplot(2,1,2);plot(ph/pi,an);grid;
ylabel('Phase in radians');xlabel('normalised frequency')
title('Phase response of Butterworth Band Reject Filter');