Professional Documents
Culture Documents
20BEC1042
EXPERIMENT 7
STUDY THE CHARACTERISITICS OF IIR FILTER
Program code:
clc
close all
clear all
%Butterworth LPF
N=2
[b1,a1]=butter(N,0.5,'low');
[h,w]=freqz(b1,a1);
figure(1)
plot(abs(h),'b','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Butterworth LowPass Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on
N=5
[b1,a1]=butter(N,0.5,'low');
[h,w]=freqz(b1,a1);
plot(abs(h),'r','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=butter(N,0.5,'low');
[h,w]=freqz(b1,a1);
plot(abs(h),'k','LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
N=5
[b1,a1]=butter(N,0.5,'high');
[h,w]=freqz(b1,a1);
plot(abs(h),'r','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=butter(N,0.5,'high');
[h,w]=freqz(b1,a1);
plot(abs(h),'k','LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
%Butterworth BPF
N=2
[b1,a1]=butter(N,[0.2 0.5],'bandpass');
[h,w]=freqz(b1,a1);
figure(3)
plot(abs(h),'b','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Butterworth BandPass Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on
N=5
[b1,a1]=butter(N,[0.2 0.5],'bandpass');
[h,w]=freqz(b1,a1);
plot(abs(h),'r','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=butter(N,[0.2 0.5],'bandpass');
[h,w]=freqz(b1,a1);
plot(abs(h),'k','LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
%Butterworth BRF
N=2
[b1,a1]=butter(N,[0.2 0.5],'stop');
[h,w]=freqz(b1,a1);
figure(4)
N=5
[b1,a1]=butter(N,[0.2 0.5],'stop');
[h,w]=freqz(b1,a1);
plot(abs(h),'r','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=butter(N,[0.2 0.5],'stop');
[h,w]=freqz(b1,a1);
plot(abs(h),'k','LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
%ChebychevI LPF
N=2
[b1,a1]=cheby1(N,0.5,0.2,'low');
[h,w]=freqz(b1,a1);
figure(5)
plot(abs(h),'m','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Chebychev I LowPass Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on
N=5
[b1,a1]=cheby1(N,0.5,0.2,'low');
[h,w]=freqz(b1,a1);
plot(abs(h),'c','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=cheby1(N,0.5,0.2,'low');
[h,w]=freqz(b1,a1);
plot(abs(h),'LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
%Chebychev I HPF
N=2
[b1,a1]=cheby1(N,0.5,0.4,'high');
[h,w]=freqz(b1,a1);
figure(6)
plot(abs(h),'m','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Chebychev I HighPass Filter','fontsize',12, 'fontweight', 'bold')
N=5
[b1,a1]=cheby1(N,0.5,0.4,'high');
[h,w]=freqz(b1,a1);
plot(abs(h),'c','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=cheby1(N,0.5,0.4,'high');
[h,w]=freqz(b1,a1);
plot(abs(h),'LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
%Chebychev I BPF
N=2
[b1,a1]=cheby1(N,0.5,[0.2 0.4],'bandpass');
[h,w]=freqz(b1,a1);
figure(7)
plot(abs(h),'m','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Chebychev I BandPass Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on
N=5
[b1,a1]=cheby1(N,0.5,[0.2 0.4],'bandpass');
[h,w]=freqz(b1,a1);
plot(abs(h),'c','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=cheby1(N,0.5,[0.2 0.4],'bandpass');
[h,w]=freqz(b1,a1);
plot(abs(h),'LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
%Chebychev I BRF
N=2
[b1,a1]=cheby1(N,0.5,[0.2 0.4],'stop');
[h,w]=freqz(b1,a1);
figure(8)
plot(abs(h),'m','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Chebychev I BandReject Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on
N=5
[b1,a1]=cheby1(N,0.5,[0.2 0.4],'stop');
N=10
[b1,a1]=cheby1(N,0.5,[0.2 0.4],'stop');
[h,w]=freqz(b1,a1);
plot(abs(h),'LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
%ChebychevII LPF
N=2
[b1,a1]=cheby2(N,20,0.2,'low');
[h,w]=freqz(b1,a1);
figure(9)
plot(abs(h),'r','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Chebychev II LowPass Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on
N=5
[b1,a1]=cheby2(N,20,0.2,'low');
[h,w]=freqz(b1,a1);
plot(abs(h),'g','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=cheby2(N,20,0.2,'low');
[h,w]=freqz(b1,a1);
plot(abs(h),'LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
%Chebychev II HPF
N=2
[b1,a1]=cheby2(N,20,0.4,'high');
[h,w]=freqz(b1,a1);
figure(10)
plot(abs(h),'r','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Chebychev II HighPass Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on
N=5
[b1,a1]=cheby2(N,20,0.4,'high');
[h,w]=freqz(b1,a1);
plot(abs(h),'g','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=cheby2(N,20,0.4,'high');
[h,w]=freqz(b1,a1);
plot(abs(h),'LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
%Chebychev II BPF
N=2
[b1,a1]=cheby2(N,20,[0.2 0.4],'bandpass');
[h,w]=freqz(b1,a1);
figure(11)
plot(abs(h),'r','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Chebychev II BandPass Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on
N=5
[b1,a1]=cheby2(N,20,[0.2 0.4],'bandpass');
[h,w]=freqz(b1,a1);
plot(abs(h),'g','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=cheby2(N,20,[0.2 0.4],'bandpass');
[h,w]=freqz(b1,a1);
plot(abs(h),'LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
%Chebychev II BRF
N=2
[b1,a1]=cheby2(N,20,[0.2 0.4],'stop');
[h,w]=freqz(b1,a1);
figure(12)
plot(abs(h),'r','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Chebychev II BandReject Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on
N=5
[b1,a1]=cheby2(N,20,[0.2 0.4],'stop');
[h,w]=freqz(b1,a1);
plot(abs(h),'g','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=cheby2(N,20,[0.2 0.4],'stop');
[h,w]=freqz(b1,a1);
plot(abs(h),'LineWidth',2)
%Elliptic LPF
N=2
[b1,a1]=ellip(N,0.5,20,0.2,'low');
[h,w]=freqz(b1,a1);
figure(13)
plot(abs(h),'b','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Elliptic LowPass Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on
N=5
[b1,a1]=ellip(N,0.5,20,0.2,'low');
[h,w]=freqz(b1,a1);
plot(abs(h),'m','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=ellip(N,0.5,20,0.2,'low');
[h,w]=freqz(b1,a1);
plot(abs(h),'k','LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
%Elliptic HPF
N=2
[b1,a1]=ellip(N,0.5,20,0.4,'high');
[h,w]=freqz(b1,a1);
figure(14)
plot(abs(h),'b','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Elliptic HighPass Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on
N=5
[b1,a1]=ellip(N,0.5,20,0.4,'high');
[h,w]=freqz(b1,a1);
plot(abs(h),'m','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=ellip(N,0.5,20,0.4,'high');
[h,w]=freqz(b1,a1);
plot(abs(h),'k','LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
N=5
[b1,a1]=ellip(N,0.5,20,[0.2 0.4],'bandpass');
[h,w]=freqz(b1,a1);
plot(abs(h),'m','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=ellip(N,0.5,20,[0.2 0.4],'bandpass');
[h,w]=freqz(b1,a1);
plot(abs(h),'k','LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
%Elliptic BRF
N=2
[b1,a1]=ellip(N,0.5,20,[0.2 0.4],'stop');
[h,w]=freqz(b1,a1);
figure(16)
plot(abs(h),'b','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Elliptic BandReject Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on
N=5
[b1,a1]=ellip(N,0.5,20,[0.2 0.4],'stop');
[h,w]=freqz(b1,a1);
plot(abs(h),'m','LineWidth',2)
grid on
hold on
N=10
[b1,a1]=ellip(N,0.5,20,[0.2 0.4],'stop');
[h,w]=freqz(b1,a1);
plot(abs(h),'k','LineWidth',2)
grid on
hold on
legend('N=2','N=5','N=10')
Outputs:
Result: We have thus performed the characteristic analysis of the various IIR
lowpass, high-pass, bandpass and band-reject filters of the type Butterworth,
Chebyshev I, Chebyshev II and Elliptic each.
We observed that as the order of the filter (N) increases, the curve narrows
down and becomes steeper. Thus, we can infer that as N increases, the filter
becomes more ideal and reaches the ideal transition region.
Output verification: