Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
70 views14 pages

Irwin Jeremy A. Isip: 1.) Analog Filter Design A.) Butterworth Filter Design

Discrete-Time Signals and Systems

Uploaded by

Isip Isip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views14 pages

Irwin Jeremy A. Isip: 1.) Analog Filter Design A.) Butterworth Filter Design

Discrete-Time Signals and Systems

Uploaded by

Isip Isip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Irwin Jeremy A.

Isip
2014-46560

Lab 10

IIR FILTERS
1.) Analog Filter Design ............................................................................................................................. 1
a.) Butterworth Filter Design .................................................................................................................... 1
b.) Chebyshev Type 1 ................................................................................................................................ 2
c.) Chebyshev Type 2 ................................................................................................................................ 3
d.) Comparison .......................................................................................................................................... 4
2.) Analog Filter Transformation ............................................................................................................... 4
a.) Lowpass to Highpass ............................................................................................................................ 5
b.) Lowpass to Bandpass ........................................................................................................................... 6
c.) Lowpass to Bandstop ........................................................................................................................... 7
3.) Analog to Digital Filter Transformation ............................................................................................... 8
a.) Impulse-Invariance Technique ............................................................................................................. 8
b.) Bilinear Transformation ....................................................................................................................... 9
c.) Digital filter design version of cheby1 ................................................................................................ 10
4. Digital IIR Filter Design ........................................................................................................................ 11
Wp < Ws, Lowpass. ................................................................................................................................. 11
a.) ............................................................................................................................................................ 11
Butterworth ............................................................................................................................................ 11
Chebyshev Type 1 ................................................................................................................................... 11
Chebyshev Type 2 ................................................................................................................................... 11
Elliptic ...................................................................................................................................................... 12
b.) Implementation ................................................................................................................................. 12
1.) Analog Filter Design
a.) Butterworth Filter Design
R_p = 20*log(0.99);
R_s = 20*log(0.01);
w_p = 1500*2*pi;
w_s = 2000*2*pi;
N_1a = 23;
w_c = 1633.939331*2*pi;
[z_1a,p_1a,k_1a] = butter(N_1a,w_c,'s');
[b_1a,a_1a] = zp2tf(z_1a,p_1a,k_1a);
[h_1a,w_1a] = freqs(b_1a,a_1a);
plot(w_1a,20*log10(abs(h_1a)))
hold on

b.) Chebyshev Type 1


N_1b = 10;
[z_1b,p_1b,k_1b] = cheby1(N_1b,-1*R_p,w_p,'s');
[b_1b,a_1b] = zp2tf(z_1b,p_1b,k_1b);
[h_1b,w_1b] = freqs(b_1b,a_1b);
plot(w_1b,20*log10(abs(h_1b)))
hold on
c.) Chebyshev Type 2
N_1c = 10;
[z_1c,p_1c,k_1c] = cheby2(N_1c,-1*R_s,w_s,'s');
[b_1c,a_1c] = zp2tf(z_1c,p_1c,k_1c);
[h_1c,w_1c] = freqs(b_1c,a_1c);
plot(w_1c,20*log10(abs(h_1c)))
title('Analog Filter Design Magnitude Response')
xlabel('Not Normalized Frequency, w, rad/s')
ylabel('H(w), dB')
legend('Butterworth','Chebyshev Type 1','Chebyshev Type 2')
hold off
d.) Comparison
% 1. Order
% Butterworth filter has greatest filter order. The two types of Chebyshev filter has the same
order.
% 2. Width of transition region
% Chebyshev type 1 and Chebyshev type 2 filters has shorter transition
% regions than in butterworth.
% 3. Passband Ripple
% The butterworth filter has maximally flat passband hence minimal ripples. The Chebyshev type 2
has small-width passband hence ripple is also minimal. The Chebyshev type 1 has observable ripple
when zoomed in.
% 4. Stopband Ripple
% The butterworth and chebyshev type 1 filter has no noticeable ripples in the stopband. The
Chebyshev type 2 has noticeable ripples in the stopband.

2.) Analog Filter Transformation


[z_2,p_2,k_2] = cheb1ap(20,0.0873);
[num_2,den_2] = zp2tf(z_2,p_2,k_2);
[h_2,w_2] = freqs(num_2,den_2);
plot(w_2,20*log10(abs(h_2)))
xlabel('Not Normalized Frequency (rad/s)')
ylabel('dB')
title('Cheb1ap')
a.) Lowpass to Highpass
[num_2a,den_2a] = lp2hp(num_2,den_2,500*2*pi);
[h_2a,w_2a] = freqs(num_2a,den_2a);
plot(w_2a,20*log10(abs(h_2a)))
title('Lowpass to Highpass')
xlabel('Not Normalized Frequency (rad/s)')
ylabel('dB')
b.) Lowpass to Bandpass
w1 = 1000*2*pi;
w2 = 2000*2*pi;
BW = w2 - w1;
w0 = sqrt(w1*w2);
[num_2b,den_2b] = lp2bp(num_2,den_2,w0,BW);
[h_2b,w_2b] = freqs(num_2b,den_2b);
plot(w_2b,20*log10(abs(h_2b)))
title('Lowpass to Bandpass')
xlabel('Not Normalized Frequency (rad/s)')
ylabel('dB')
c.) Lowpass to Bandstop
[num_2c, den_2c] = lp2bs(num_2,den_2,w0,BW);
[h_2c,w_2c] = freqs(num_2c,den_2c);
plot(w_2c,20*log10(abs(h_2c)))
title('Lowpass to bandstop')
xlabel('Not Normalized Frequency (rad/s)')
ylabel('dB')
3.) Analog to Digital Filter Transformation
a.) Impulse-Invariance Technique
fs = 8000;
[b_3a0,a_3a0] = cheby1(N_1b,-1*R_p,w_p,'s');
%[h_3a0,w_3a0] = freqs(b_3a0,a_3a0);
[b_3a,a_3a] = impinvar(b_3a0,a_3a0,8000);
freqz(b_3a,a_3a,200);
title('Impulse-Invariance Technique')
%plot(w_3a,20*log10(abs(h_3a)))
%title('Impulse-Invariance Technique')
b.) Bilinear Transformation
[b_3b,a_3b] = bilinear(b_3a0,a_3a0,fs);
freqz(b_3b,a_3b)
title('Bilinear Transformation')
c.) Digital filter design version of cheby1
lpfilt = designfilt('lowpassiir', 'PassbandFrequency', 0.1875, 'StopbandFrequency', 0.25,
'PassbandRipple', -1*R_p, 'StopbandAttenuation', -1*R_s);
freqz(lpfilt)

%
% The bilinear and designfilt outputs are similar while the impulse invariance
% output is different.
%
% The designfilt function outputs a similar magnitude and phase response
% with the bilinear transformation. Hence, the bilinear transformation is
% the default.
%
4. Digital IIR Filter Design
Wp < Ws, Lowpass.
a.)
Butterworth
Wp_4 = 8000/40000;
Ws_4 = 16000/40000;
Rp_4 = 0.2;
Rs_4 = 60;

[N_b,Wn_b] = buttord(Wp_4,Ws_4,Rp_4,Rs_4);
disp(N_b)

11

Chebyshev Type 1
[N_c1, Wn_c1] = cheb1ord(Wp_4,Ws_4,Rp_4,Rs_4);
disp('N= ')
disp(N_c1)

N=
7

Chebyshev Type 2
[N_c2, Wn_c2] = cheb2ord(Wp_4,Ws_4,Rp_4,Rs_4);
disp('N= ')
disp(N_c2)
N=
7

Elliptic
[N_e, Wn_e] = ellipord(Wp_4,Ws_4,Rp_4,Rs_4);
disp('N= ')
disp(N_e)

% The butterworth has the greatest magnitude followed by the chebyshev type 1 and 2 and then the
elliptic.
%
%
%
%

N=
5

b.) Implementation
[z_4b1,p_4b1,k_4b1] = butter(N_b,Wn_b);
sos1 = zp2sos(z_4b1,p_4b1,k_4b1);
fvtool(sos1)
title('Butterworth')

[z_4b2,p_4b2,k_4b2] = cheby1(N_c1,Rp_4,Wp_4);
sos2 = zp2sos(z_4b2,p_4b2,k_4b2);
fvtool(sos2)
title('Chebyshev 1')

[z_4b3,p_4b3,k_4b3] = cheby2(N_c2,Rs_4,Ws_4);
sos3 = zp2sos(z_4b3,p_4b3,k_4b3);
fvtool(sos3)
title('Chebyshev 2')

[z_4b4,p_4b4,k_4b4] = ellip(N_e,Rp_4,Rs_4,Wp_4);
sos4 = zp2sos(z_4b4,p_4b4,k_4b4);
fvtool(sos4)
title('Elliptic')
% The elliptic and chebyshev type 2 approximation's frequency responses meet the specifications.
%
% The butterworth and chebyshev type 1 approximation's frequency responses deviate a little from
the specifications.
%
%
Published with MATLAB® R2020b

You might also like