Program 3b
Program 3b
n = 3
fs = 20 % fs is a sampling frequency
fs = 20
f = 3
fr = 18.8496
% 'butter' use for butterworth filter and 's' use for analog filter by default it gives
% low pass filter
[b,a] = butter(n,fr,'s')
b = 1×4
103 ×
0 0 0 6.6974
a = 1×4
103 ×
0.0010 0.0377 0.7106 6.6974
bz = 1×4
0.0420 0.1260 0.1260 0.0420
az = 1×4
1.0000 -1.2782 0.7736 -0.1594
% 'freqz' use for Frequency response of digital filter, being calculated at 1024 points
freqz(bz,az,1024,fs)
1
Design a high bandpass filter from analog to digital filter using impulse bilinear transformation
method :-
n = 3 % n is a filter order
n = 3
fs = 10 % fs is a sampling frequency
fs = 10
f = 3
fr = 18.8496
% 'butter' use for butterworth filter and 's' use for analog filter and 'high' use for
% high pass filter
[b,a] = butter(n,fr,'high','s')
b = 1×4
1 0 0 0
a = 1×4
103 ×
2
0.0010 0.0377 0.7106 6.6974
bz = 1×4
0.1819 -0.5456 0.5456 -0.1819
az = 1×4
1.0000 -0.1086 0.3365 -0.0099
% 'freqz' use for Frequency response of digital filter, being calculated at 1024 points
freqz(bz,az,1024,fs)
Design a stop band filter from analog to digital filter using impulse bilinear transformation method :-
n = 3 % n is a filter order
n = 3
fs = 20 % fs is a sampling frequency
fs = 20
f1 = 3
f2 = 6
3
% For analog filters frequency must be in radians per second
fr1 = 2*pi*f1 % fr1 is a first frequency in radians per second
fr1 = 18.8496
fr2 = 37.6991
% 'butter' use for butterworth filter and 's' use for analog filter and 'stop' use for
% stopband filter
[b,a] = butter(n,[fr1,fr2],'stop','s')
b = 1×7
108 ×
0.0000 0 0.0000 0 0.0151 0 3.5884
a = 1×7
108 ×
0.0000 0.0000 0.0000 0.0006 0.0202 0.1904 3.5884
bz = 1×7
0.5262 -1.2153 2.5143 -2.6707 2.5143 -1.2153 0.5262
az = 1×7
1.0000 -1.8303 2.8943 -2.4982 1.9101 -0.7728 0.2766
% 'freqz' use for Frequency response of digital filter, being calculated at 1024 points
freqz(bz,az,1024,fs)
4
Design a pass band filter from analog to digital filter using impulse bilinear transformation method :-
n = 3 % n is a filter order
n = 3
fs = 20 % fs is a sampling frequency
fs = 20
f1 = 3
f2 = 6
fr1 = 18.8496
fr2 = 37.6991
% 'butter' use for butterworth filter and 's' use for analog filter and 'bandpass' use for
% pass band filter
5
[b,a] = butter(n,[fr1,fr2],'bandpass','s')
b = 1×7
103 ×
0 0 0 6.6974 0 0 0
a = 1×7
108 ×
0.0000 0.0000 0.0000 0.0006 0.0202 0.1904 3.5884
bz = 1×7
0.0183 -0.0000 -0.0549 -0.0000 0.0549 0.0000 -0.0183
az = 1×7
1.0000 -1.8303 2.8943 -2.4982 1.9101 -0.7728 0.2766
% 'freqz' use for Frequency response of digital filter, being calculated at 1024 points
freqz(bz,az,1024,fs)