Exp 4
Exp 4
AIM:
To write a MATLAB Script to design a IIR Butterworth / Chebyshev low pass filter using
i. Bilinear Transformation
ii. Impulse Invariant Transformation
.
APPARATUS REQUIRED:
Computer with MATLAB software
THEORY:
A digital filter is a linear time invariant discrete time system. The digital filters are classified
into two, based on their lengths of impulse response
1. Finite Impulse response (FIR)
They are of non-recursive type and h [n] has finite number of samples
2. Infinite Impulse response (IIR)
h[n] has infinite number of samples. They are of recursive type. Hence, their transfer
function is of the form
H ( z ) h( n ) z n
n 0
M 1
bk Z k
H (Z ) K 0
N 1
1 a jZ j
j 1
BUTTERWORTH FILTER:
Low pass Analog Butterworth filters are all pole filters characterised by magnitude frequency
response by
1
H ( j ) 2 =
2N
1
c
where N is the order of the filter and c is the cut-off frequency.
As N , the low pass filter is said to be ideal. All types of filters namely-Low pass, High
pass, Band pass and Band elimination filters can be derived from the Normalized Low pass
filter.
CHEBYSHEV FILTER:
There are two types of Chebyshev filters.
Type I are all-pole filters that exhibit equi-ripple behaviour in pass band and monotonic
characteristics in stop band.
15
Type II are having both poles and zeros and exhibit monotonic behavior in pass band and
equi-ripple behaviour in stop band. The zero lies on the imaginary axis.
BILINEAR TRANSFORMATION:
DESIGN STEPS:
1. From the given specifications, find pre-warped analog frequencies using
2
tan
T 2
2. Using the analog frequencies, find H(s) of the analog filter
2 1 Z 1
3. Substitute S in the H(s) of Step:2
T 1 Z 1
k 1
LIBRARY FUNCTIONS:
butter: Butterworth digital and analog filter design.
[B, A] = butter (N,Wn) designs an Nth order Low pass digital Butterworth filter and
returns the filter coefficient vectors B (numerator) and A (denominator) in length
16
N+1. The coefficients are listed in descending powers of z. The cut-off frequency Wn
must be in the range 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.
Lowpass: Wp = .1, Ws = .2
Highpass: Wp = .2, Ws = .1
Bandpass: Wp = [.2 .7], Ws = [.1 .8]
Bandstop: Wp = [.1 .8], Ws = [.2 .7]
buttord: also returns Wn, the Butterworth natural frequency (or) the "3 dB frequency" to be
used with BUTTER to achieve the specifications.
[N, Wn] = buttord (Wp, Ws, Rp, Rs, 's') does the computation for an analog filter, in which
case Wp and Ws are in radians/second. When Rp is chosen as 3 dB, the Wn in BUTTER is
equal to Wp in BUTTORD.
Lowpass: Wp = .1, Ws = .2
Highpass: Wp = .2, Ws = .1
Bandpass: Wp = [.2 .7], Ws = [.1 .8]
Bandstop: Wp = [.1 .8], Ws = [.2 .7]
cheb1ord also returns Wn, the Chebyshev natural frequency to use with cheby1 to
achieve the specifications.
[N, Wn] = cheb1ord (Wp, Ws, Rp, Rs, 's') does the computation for an analog filter,
in which case Wp and Ws are in radians/second.
cheby1: Chebyshev Type I digital and analog filter design.
17
[B,A] = cheby1 (N,R,Wn) designs an Nth order Low pass digital Chebyshev filter
with R decibels of peak-to-peak ripple in the pass band. cheby1 returns the filter
coefficient vectors B (numerator) and A (denominator) of length N+1. The cut-off
frequency Wn must be in the range 0.0 < Wn < 1.0, with 1.0 corresponding to half the
sample rate. Use R=0.5 as a starting point, if you are unsure about choosing R.
given the numerator and denominator coefficients in vectors B and A. The frequency
response is evaluated at the points specified in vector W (in rad/s). The magnitude
and phase can be graphed by calling freqs(B,A,W) with no output arguments.
Bilinear: Bilinear transformation method for analog-to-digital filter conversion. The bilinear
transformation is a mathematical mapping of variables. In digital filtering, it is a standard
method of mapping the s or analog plane into the z or digital plane. It transforms analog
filters, designed using classical filter design.
RESULT:
18
Experiment 4
DATE: 17.02.2025 REGISTER NUMBER: URK23EC1015
close all;
ap=0.8;
as=0.2;
wp=0.2*pi;
ws=0.6*pi;
ap1=20*log(0.8);
as1=20*log(0.2);
T=2;
wp1=wp/T;
ws1=ws/T;
[N,wc]=buttord(wp1,ws1,ap1,as1);
[b,a]=butter(N,wc,'low','s');
% tf(b,a)
[B,A] = impinvar(b,a,1/T);
freqz(B,A)
Output:
2)Design of Butterworth filter using Bilinear method:
Code:
clc;
clear;
close all;
ap=0.8;
as=0.2;
wp=0.2*pi;
ws=0.6*pi;
ap1=20*log(ap);
as1=20*log(as);
T=1;
wp1=2/T*tan(wp*T/2);
ws1=2/T*tan(ws*T/2);
[N,wc]=buttord(wp1,ws1,ap1,as1,'s');
[b,a]=butter(N,wc,'low','s');
% tf(b,a);
[b,a] = bilinear(b,a,1/T);
freqz(b,a);
title('BILINEAR TRANSFORMATION');
Output:
3)Design of Chebyshev filter using Impulse Invariant method:
Code:
clc;
ap = 0.8;
as = 0.2;
wp = 0.2*pi;
ws = 0.6*pi;
Ap1 = 20*log10(ap);
As1 = 20*log10(as);
t = 1;
Wp1 = wp/t;
Ws1 = ws/t;
% tf(B,A)
[b,a] = impinvar(B,A,1/t);
freqz(b,a)
Output:
4)Design of Chebyshev filter using Bilinear method:
Code:
clc;
clear;
close all;
Ap=0.8;
As=0.2;
Wp=0.2*pi;
Ws=0.6*pi;
T=1;
Ap1=20*log10(Ap);
As1=20*log10(As);
Wp1=(2/T)*tan(Wp*T/2);
Ws1=(2/T)*tan(Ws*T/2);
Rp=3;
[N,Wn]=cheb1ord(Wp1,Ws1,Rp,As1,'s');
[B,A]=cheby1(N,Rp,Wn,'low','s');
% tf(B,A)
[b,a]=bilinear(B,A,1/T);
freqz(b,a)
Output: