You are on page 1of 17

17/09/2022 R Meghana

20BEC1042

EXPERIMENT 7
STUDY THE CHARACTERISITICS OF IIR FILTER

Aim: To perform the characteristic analysis of the following infinite impulse


response (IIR) filters:
 Butterworth
 Chebyshev I
 Chebyshev II
 Elliptic
And to vary the order of the filter (N) to 2, 5, 10 and observe the characteristic
change according to the order.

Software Required: MATLAB

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')

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042
%Butterworth HPF
N=2
[b1,a1]=butter(N,0.5,'high');
[h,w]=freqz(b1,a1);
figure(2)
plot(abs(h),'b','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Butterworth HighPass Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on

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)

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042
plot(abs(h),'b','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Butterworth BandReject Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on

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')

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042
grid on
hold on

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');

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042
[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],'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

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042

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)

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042
grid on
hold on
legend('N=2','N=5','N=10')

%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')

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042
%Elliptic BPF
N=2
[b1,a1]=ellip(N,0.5,20,[0.2 0.4],'bandpass');
[h,w]=freqz(b1,a1);
figure(15)
plot(abs(h),'b','LineWidth',2)
xlabel('frequency', 'fontsize', 10, 'fontweight', 'bold');
ylabel('|H(w)|', 'fontsize', 10, 'fontweight', 'bold');
title('Elliptic BandPass Filter','fontsize',12, 'fontweight', 'bold')
grid on
hold on

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')

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042

Outputs:

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042

ECE2006-Digital Signal Processing Lab


L31+L32
17/09/2022 R Meghana
20BEC1042

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:

ECE2006-Digital Signal Processing Lab


L31+L32

You might also like