Here I am providing the required Matlab Program to execute IIR - Filters i.e. Butterworth, Chebshev Type-I, Chebshev Type-II. Unlike Previously stated, write these programs in some book/paper. Don't write these programs directly in observations. After executing the programs you have to write in observations.
So, the following are the Programs:
1) Butterworth IIR Low-Pass Filter
2) Butterworth IIR High-Pass Filter
3) Chebshev Type-I IIR Low-Pass Filter
4) Chebshev Type-II IIR High-Pass Filter
5) Chebshev Type-II IIR Low-Pass Filter
6) Chebshev Type-II IIR High-Pass Filter
The respective code's are as follows:
IIR Filters
Program 1:
%Program to find frequency respnse of butterworth IIR analog Low-pass Filter
wp=input('enter passband cuttoff frequency:');
ws=input('enter stopband cuttoff frequency:');
rp=input('enter passband ripple in db:');
rs=input('enter stop band ripple in db:');
fs=input('enter the sampling frequency:');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
[b,a]=butter(n,wn,'s');
w=0:0.01:pi;
[h,omega]=freqs(b,a,w);
gain=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
title('magnitude response of LPF');
plot(omega/pi,gain);
xlabel('normalized frequency');
ylabel('phase in radians');
subplot(2,1,2);
title('phase in radians');
plot(omega/pi,an);
xlabel('normalized frequency');
ylabel('phase in radians');
Program 2:
%Program to find frequency respnse of butterworth IIR analog High-pass Filter
wp=input('enter passband cuttoff frequency:');
ws=input('enter stopband cuttoff frequency:');
rp=input('enter passband ripple in db:');
rs=input('enter stop band ripple in db:');
fs=input('enter the sampling frequency:');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
[b,a]=butter(n,wn,'high','s');
w=0:0.01:pi;
[h,omega]=freqs(b,a,w);
gain=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
title('magnitude response of LPF');
plot(omega/pi,gain);
xlabel('normalized frequency');
ylabel('phase in radians');
subplot(2,1,2);
title('phase in radians');
plot(omega/pi,an);
xlabel('normalized frequency');
ylabel('phase in radians');
Program 3:
%Program to find frequency respnse of Chebyshev Type-I IIR analog Low-pass Filter
wp=input('enter passband cuttoff frequency:');
ws=input('enter stopband cuttoff frequency:');
rp=input('enter passband ripple in db:');
rs=input('enter stop band ripple in db:');
fs=input('enter the sampling frequency:');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=cheb1ord(w1,w2,rp,rs,'s');
[b,a]=cheby1(n,wn,'s');
w=0:0.01:pi;
[h,omega]=freqs(b,a,w);
gain=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
title('magnitude response of LPF');
plot(omega/pi,gain);
xlabel('normalized frequency');
ylabel('phase in radians');
subplot(2,1,2);
title('phase in radians');
plot(omega/pi,an);
xlabel('normalized frequency');
ylabel('phase in radians');
Program 4:
%Program to find frequency respnse of Chebyshev Type-I IIR analog High-pass Filter
wp=input('enter passband cuttoff frequency:');
ws=input('enter stopband cuttoff frequency:');
rp=input('enter passband ripple in db:');
rs=input('enter stop band ripple in db:');
fs=input('enter the sampling frequency:');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=cheb1ord(w1,w2,rp,rs,'s');
[b,a]=cheby1(n,wn,'high','s');
w=0:0.01:pi;
[h,omega]=freqs(b,a,w);
gain=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
title('magnitude response of LPF');
plot(omega/pi,gain);
xlabel('normalized frequency');
ylabel('phase in radians');
subplot(2,1,2);
title('phase in radians');
plot(omega/pi,an);
xlabel('normalized frequency');
ylabel('phase in radians');
Program 5:
%Program to find frequency respnse of Chebyshev Type-II IIR analog Low-pass Filter
wp=input('enter passband cuttoff frequency:');
ws=input('enter stopband cuttoff frequency:');
rp=input('enter passband ripple in db:');
rs=input('enter stop band ripple in db:');
fs=input('enter the sampling frequency:');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=cheb2ord(w1,w2,rp,rs,'s');
[b,a]=cheby2(n,wn,'s');
w=0:0.01:pi;
[h,omega]=freqs(b,a,w);
gain=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
title('magnitude response of LPF');
plot(omega/pi,gain);
xlabel('normalized frequency');
ylabel('phase in radians');
subplot(2,1,2);
title('phase in radians');
plot(omega/pi,an);
xlabel('normalized frequency');
ylabel('phase in radians');
Program 6:
%Program to find frequency respnse of Chebyshev Type-II IIR analog High-pass Filter
wp=input('enter passband cuttoff frequency:');
ws=input('enter stopband cuttoff frequency:');
rp=input('enter passband ripple in db:');
rs=input('enter stop band ripple in db:');
fs=input('enter the sampling frequency:');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=cheb2ord(w1,w2,rp,rs,'s');
[b,a]=cheby2(n,wn,'high','s');
w=0:0.01:pi;
[h,omega]=freqs(b,a,w);
gain=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
title('magnitude response of LPF');
plot(omega/pi,gain);
xlabel('normalized frequency');
ylabel('phase in radians');
subplot(2,1,2);
title('phase in radians');
plot(omega/pi,an);
xlabel('normalized frequency');
ylabel('phase in radians');
Do execute these programs and then write in observations. And get it corrected as early as possible.
with regards,
B V K
No comments:
Post a Comment