Zhongguo Liu_Biomedical Engineering_Shandong Univ. Biomedical Signal processing Chapter 7 Filter Design Techniques Zhongguo Liu Biomedical Engineering School of Control Science and Engineering, Shandong University
2 Chapter 7 Filter Design Techniques 7.0 Introduction 7.1 Design of Discrete-Time IIR Filters From Continuous-Time Filters 7.2 Design of FIR Filters by Windowing 7.3 Examples of FIR Filters Design by the Kaiser Window Method 7.4 Optimum Approximations of FIR Filters 7.5 Examples of FIR Equiripple Approximation 7.6 Comments on IIR and FIR Discrete-Time Filters
3 Filter Design Techniques 7.0 Introduction
4 Frequency-selective filters pass only certain frequencies Any discrete-time system that modifies certain frequencies is called a filter. We concetrate on design of causal Frequency-selective filters
5 Stages of Filter Design The specification of the desired properties of the system. The approximation of the specifications using a causal discrete-time system. The realization of the system. Our focus is on second step Specifications are typically given in the frequency domain.
6 Frequency-Selective Filters Ideal lowpass filter
7 Frequency-Selective Filters Ideal highpass filter
8 Frequency-Selective Filters Ideal bandpass filter
9 Frequency-Selective Filters Ideal bandstop filter
10 If input is bandlimited and sampling frequency is high enough to avoid aliasing, then overall system behave as a continuous-time system: Linear time-invariant discrete-time system continuous-time specifications are converted to discrete time specifications by:
11 Example 7.1 Determining Specifications for a Discrete-Time Filter Specifications of the continuous-time filter: 1. passband 2. stopband
12 Example 7.1 Determining Specifications for a Discrete-Time Filter Specifications of the continuous-time filter: 1. passband 2. stopband
13 Example 7.1 Determining Specifications for a Discrete-Time Filter Specifications of the discrete-time filter in
14 Filter Design Constraints Designing IIR filters is to find the approximation by a rational function of z. The poles of the system function must lie inside the unit circle(stability, causality). Designing FIR filters is to find the polynomial approximation. FIR filters are often required to be linear- phase.
15 Filter Design Techniques 7.1 Design of Discrete-Time IIR Filters From Continuous-Time Filters
Design of Discrete-Time IIR Filters From Continuous-Time Filters The traditional approach to the design of discrete-time IIR filters involves the transformation of a continuous-time filter into a discrete filter meeting prescribed specification.
17 Three Reasons 1.The art of continuous-time IIR filter design is highly advanced, and since useful results can be achieved, it is advantageous to use the design procedures already developed for continuous-time filters.
18 Three Reasons 2.Many useful continuous-time IIR design method have relatively simple closed form design formulas. Therefore, discrete-time IIR filter design methods based on such standard continuous-time design formulas are rather simple to carry out.
19 Three Reasons The standard approximation methods that work well for continuous-time IIR filters do not lead to simple closed-form design formulas when these methods are applied directly to the discrete-time IIR case, because the frequency response of a discrete- time filter is periodic, and that of a continuous-time filter is not..
20 Steps of DT filter design by transforming a prototype continuous-time filter The specifications for the continuous- time filter are obtained by a transformation of the specifications for the desired discrete-time filter. Find the system function of the continuous-time filter. Transform the continuous-time filter to derive the system function of the discrete-time filter.
21 Constraints of Transformation to preserve the essential properties of the frequency response, the imaginary axis of the s-plane is mapped onto the unit circle of the z-plane.
22 Constraints of Transformation In order to preserve the property of stability, If the continuous system has poles only in the let half of the s-plane, then the discrete-time filter must have poles only inside the unit circle.
Filter Design by Impulse Invariance The impulse response of discrete-time system is defined by sampling the impulse response of a continuous-time system. Relationship of frequencies
24 relation between frequencies S plane Z plane - Relationship of frequencies
25 No Aliasing in the Impulse Invariance
26 Aliasing in the Impulse Invariance
27 periodic sampling T : sample period; fs=1/T:sample rate Ωs=2π/T:sample rate Review
28 Time domain : Complex frequency domain : Laplace transform Relation between Laplace Transform and Z-transform Review
29 Fourier Transform frequency domain : Laplace transform Fourier Transform is the Laplace transform when s have the value only in imaginary axis, s=jΩ Since So
30 For discrete-time signal , 令: z-transform of discrete- time signal Laplace transform the Laplace transform
31 so : Laplace transform Laplace transform continuous time signal z-transform z-transform discrete-time signal let :
32 DTFT : Discrete Time Fourier Transform S plane Z plane -
33 plane
34 If input is bandlimited and f s >2f max, : discrete-time filter design by impulse invariance
35 relation between frequencies S plane Z plane - Relationship of frequencies
36 periodic sampling T : sample period; fs=1/T:sample rate Ωs=2π/T:sample rate Review
37 proof of T : sample period; fs=1/T:sample rate;Ωs=2π/T:sample rate Review s(t) 为冲击串序列,周期为 T ,可展开傅立叶级数
38 periodic sampling
39 discrete-time filter design by impulse invariance
40 Steps of DT filter design by transforming a prototype continuous-time filter Obtain the specifications for continuous- time filter by transforming the specifications for the desired discrete-time filter. Find the system function of the continuous- time filter. Transform the continuous-time filter to derive the system function of the discrete- time filter.
41 Transformation of specifications from discrete to continuous In the impulse invariance design procedure, Assuming the aliasing involved in the transformation is neglected, the relation of specifications in transformation is
42 Steps of DT filter design by transforming a prototype continuous-time filter Obtain the specifications for continuous- time filter by transforming the specifications for the desired discrete-time filter. Find the system function of the continuous- time filter. Transform the continuous-time filter to derive the system function of the discrete- time filter.
43 Continuous-time IIR filters Butterworth filters Chebyshev Type I filters Chebyshev Type II filters Elliptic filters
44 Steps of DT filter design by transforming a prototype continuous-time filter Obtain the specifications for continuous- time filter by transforming the specifications for the desired discrete-time filter. Find the system function of the continuous- time filter. Transform the continuous-time filter to derive the system function of the discrete- time filter.
45 Transformation from continuous to discrete
46 Ex. 7.2 design DT filter by Impulse Invariance with a Butterworth Filter Specifications for the discrete-time filter: Assume the effect of aliasing is negligible Solution:
47 Example 7.2 Impulse Invariance with a Butterworth Filter monotonic function of frequency
48 Example 7.2 Impulse Invariance with a Butterworth Filter
49 Example 7.2 Impulse Invariance with a Butterworth Filter allows some margin for aliasing passband specifications met exactly stopband specifications exceeded.
50 Example 7.2 Impulse Invariance with a Butterworth Filter
51 Example 7.2 Impulse Invariance with a Butterworth Filter Plole pairs: Left half of the s-plane
52 Example 7.2 Impulse Invariance with a Butterworth Filter Plole pairs:
53 Example 7.2 Impulse Invariance with a Butterworth Filter Plole pairs:
54 Example 7.2 Impulse Invariance with a Butterworth Filter
55 Example 7.2 Impulse Invariance with a Butterworth Filter Frequency response of 6th-order Butterworth filter transformed by impulse invariance. (a)Log magnitude in dB. (b)Magnitude. (c)Group delay
56 Program of Ex.7.2 using Impulse Invariance clear all; wp=.2*pi; rp=-20*log10( ); ws=.3*pi; rs=-20*log10( ); Fs=1; wap=wp/Fs; was=ws/Fs; [n,wn]=buttord(wap,was,rp,rs,'s') % Note: 's'! [z,p,k]=buttap(n); % [bp,ap]=zp2tf(z,p,k) [bs,as]=lp2lp(bp,ap,wn) [bz,az]=impinvar(bs,as,Fs) %[bs,as] = butter(n,wn,'s'); %[bz,az] = impinvar(bs,as,Fs); [Hz,Wz] = freqz(bz,az,512); subplot(311);plot(Wz,20*log10(abs(Hz)),'r');
57 Program of Ex.7.2 using Impulse Invariance [Hz,Wz] = freqz(bz,az,512); subplot(311) plot(Wz,20*log10(abs(Hz)),'r');grid on axis ([0 pi ]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',-100:20:20) set(gca,'YTickLabel',{'-100','-80','-60','-40','-20','0','20'}) xlabel('Frequency (Hz)'), ylabel('Magnitude (dB)'); title('Log Magnitude Response '); subplot(312) plot(Wz,(abs(Hz)),'r'); axis ([0 pi 0 1.2]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0:0.2:1.2) set(gca,'YTickLabel',{'0','0.2','0.4','0.6','0.8','1.0','1.2'}) xlabel('Frequency (Hz)'), ylabel('Magnitude '); title('Magnitude Response '); subplot(313) plot(Wz,(grpdelay(bz,az,Wz)),'r'); axis ([0 pi 0 12]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0:2:12) set(gca,'YTickLabel',{'0','2','4','6','8','10','12'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay ');
58 Program of Ex.7.2 using Impulse Invariance
59 Program of Ex.7.2 直接用数字滤波器设计指令 clear all; Fs=1 wp=.2*pi; rp=-20*log10( ); ws=.3*pi; rs=-20*log10( ); [n,Wn]=buttord(.2*pi/pi,0.3*pi/pi,rp,rs) % no 's'! [bz,az]=butter(n,Wn); freqz(bz,az,512, Fs) axis ([ ]) figure zplane(bz,az) [z,p,k]=tf2zp(bz,az) zplane(z,p,k)
60 Basic for Impulse Invariance To chose an impulse response for the discrete-time filter that is similar in some sense to the impulse response of the continuous-time filter. If the continuous-time filter is bandlimited, then the discrete-time filter frequency response will closely approximate the continuous-time frequency response. The relationship between continuous-time and discrete-time frequency is linear; consequently, except for aliasing, the shape of the frequency response is preserved.
Bilinear Transformation Bilinear transformation can avoid the problem of aliasing. Bilinear transformation maps onto Bilinear transformation:
Bilinear Transformation
Bilinear Transformation
Bilinear Transformation To derive a relationship between the variables w and Ω
65 relation between frequency response of H c (s), H(z)
66 Comments on the Bilinear Transformation It avoids the problem of aliasing encountered with the use of impulse invariance. It is nonlinear compression of frequency axis. S plane Z plane - S plane Z plane
67 Comments on the Bilinear Transformation The design of discrete-time filters using bilinear transformation is useful only when this compression can be tolerated or compensated for, as the case of filters that approximate ideal piecewise-constant magnitude-response characteristics.
68 Bilinear Transformation of distortion in the frequency axis also manifests the warping of the phase response of the filter frequency axis
69 Comparisons of Impulse Invariance and Bilinear Transformation The use of bilinear transformation is restricted to the design of approximations to filters with piecewise-constant frequency magnitude characteristics, such as highpass, lowpass and bandpass filters. Impulse invariance can also design lowpass filters. However, it cannot be used to design highpass filters because they are not bandlimited.
70 Comparisons of Impulse Invariance and Bilinear Transformation Bilinear transformation cannot design filter whose magnitude response isn’t piecewise constant, such as differentiator. However, Impulse invariance can design an bandlimited differentiator.
71 Butterworth Filter, Chebyshev Approximation, Elliptic Approximation Example of Bilinear Transformation
72 Example 7.3 Bilinear Transformation of a Butterworth Filter Solution:
73 Example 7.3 Bilinear Transformation of a Butterworth Filter Butterworth Filter passband specifications exceeded. no aliasing, stopband specifications met exactly
74 Locations of Poles Plole pairs:
75 Example 7.3 Bilinear Transformation of a Butterworth Filter Plole pairs:
76 Ex. 7.3 frequency response of discrete-time filter
77 Program of Ex.7.3 by Bilinear Transformation clear all; wp=.2*pi; rp=-20*log10( ); ws=.3*pi; rs=-20*log10( ); Fs=1; wap=2*Fs*tan(wp/2);was=2*Fs*tan(ws/2); [n,wn]=buttord(wap,was,rp,rs,'s') % Note: 's'! [z,p,k]=buttap(n); [bp,ap]=zp2tf(z,p,k) [bs,as]=lp2lp(bp,ap,wn) [bz,az]=bilinear(bs,as,Fs) % [bs,as] = butter(n,wn,'s'); % [bz,az]=bilinear(bs,as,Fs) [Hz,Wz] = freqz(bz,az,512); subplot(311);plot(Wz,20*log10(abs(Hz)),'r');
78 [Hz,Wz] = freqz(bz,az,512); subplot(311) plot(Wz,20*log10(abs(Hz)),'r');grid on axis ([0 pi ]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',-100:20:20) set(gca,'YTickLabel',{'-100','-80','-60','-40','-20','0','20'}) xlabel('Frequency (Hz)'), ylabel('Magnitude (dB)'); title('Log Magnitude Response '); subplot(312) plot(Wz,(abs(Hz)),'r'); axis ([0 pi 0 1.2]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0:0.2:1.2) set(gca,'YTickLabel',{'0','0.2','0.4','0.6','0.8','1.0','1.2'}) xlabel('Frequency (Hz)'), ylabel('Magnitude '); title('Magnitude Response '); subplot(313) plot(Wz,(grpdelay(bz,az,Wz)),'r'); axis ([0 pi 0 12]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0:2:12) set(gca,'YTickLabel',{'0','2','4','6','8','10','12'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay '); Program of Ex.7.3 by Bilinear Transformation
79 Program of Ex.7.3 by Bilinear Transformation
80 Program of Ex.7.3 直接用数字滤波器设计指令 clear all; Fs=1 wp=.2*pi; rp=-20*log10( ); ws=.3*pi; rs=-20*log10( ); [n,Wn]=buttord(.2*pi/pi,0.3*pi/pi,rp,rs) % no 's'! [bz,az]=butter(n,Wn); freqz(bz,az,512, Fs) axis ([ ]) figure zplane(bz,az) [z,p,k]=tf2zp(bz,az) zplane(z,p,k)
81 Butterworth Filter, Chebyshev Approximation, Elliptic Approximation Example of Bilinear Transformation
82 Example 7.4 Butterworth Approximation (Hw)
83 Example 7.4 frequency response Magnitude in passband only
84 Program of Ex.7.4 by Bilinear Transformation clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); wap=2*Fs*tan(wp/2);was=2*Fs*tan(ws/2); [n,wn]=buttord(wap,was,rp,rs,'s') % Note: 's'! [z,p,k]=buttap(n); [bp,ap]=zp2tf(z,p,k) [bs,as]=lp2lp(bp,ap,wn) [bz,az]=bilinear(bs,as,Fs) % [bs,as] = butter(n,wn,'s'); % [bz,az]=bilinear(bs,as,Fs) [Hz,Wz] = freqz(bz,az,512); Hz=Hz*(1+e);
85 [Hz,Wz] = freqz(bz,az,512); Hz=Hz*(1+e); subplot(311) plot(Wz,20*log10(abs(Hz)),'r'); axis ([0 pi ]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',-100:20:20) set(gca,'YTickLabel',{'-100','-80','-60','-40','-20','0','20'}) xlabel('Frequency (Hz)'), ylabel('Magnitude (dB)'); title('Log Magnitude Response '); subplot(312) plot(Wz,(abs(Hz)),'r'); axis ([0 pi ]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0.99:0.005:1.01) set(gca,'YTickLabel',{'0.99','0.995','1.0','1.005','1.01'}) xlabel('Frequency (Hz)'), ylabel('Magnitude '); title('Magnitude Response '); subplot(313) plot(Wz,(grpdelay(bz,az,Wz)),'r'); axis ([0 pi 0 25]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0:5:25) set(gca,'YTickLabel',{'0','5','10','15','20','25'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay '); Program of Ex.7.4 by Bilinear Transformation
86 Program of Ex.7.4 by Bilinear Transformation Frequency response
87 Program of Ex.7.4 直接用数字滤波器设计指令 clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); [n,Wn]=buttord(.4*pi/pi,0.6*pi/pi,rp,rs) [z,p,k]=butter(n,Wn); [sos,g] = zp2sos(z,p,k); Hd = dfilt.df2tsos(sos,g); h = fvtool(Hd) figure zplane(z,p,k) [bz,az]=zp2tf (z,p,k)
88 Chebyshev filters C Chebyshev filter (type I) 1 Chebyshev polynomial Chebyshev filter (type II) 1
89 Example 7.5 Chebyshev Type I, II Approximation Type I Type II
90 Example 7.5 frequency response of Chebyshev Type I Type II Magnitude in passband only
91 Program of Ex.7.5 by Bilinear Transformation % Chebyshev I 型 M 程序如下 clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); wap=2*Fs*tan(wp/2);was=2*Fs*tan(ws/2); [n,wn]=cheb1ord(wap,was,rp,rs,'s') % 's'! [z,p,k]=cheb1ap(n,rp); [bp,ap]=zp2tf(z,p,k) [bs,as]=lp2lp(bp,ap,wn) [bz,az]=bilinear(bs,as,Fs) % [bs,as] = cheby1(n,rp,wn,'s'); % [bz,az]=bilinear(bs,as,Fs)
92 Program of Ex.7.5 by Bilinear Transformation % Chebyshev II 型 M 程序如下 clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); wap=2*Fs*tan(wp/2);was=2*Fs*tan(ws/2); [n,wn]=cheb2ord(wap,was,rp,rs,'s') [z,p,k]=cheb2ap(n,rs); [bp,ap]=zp2tf(z,p,k) [bs,as]=lp2lp(bp,ap,wn) [bz,az]=bilinear(bs,as,Fs) %[bs,as] = cheby2(n,rs,wn,'s'); %[bz,az]=bilinear(bs,as,Fs)
93 [Hz,Wz] = freqz(bz,az,512); Hz=Hz*(1+e); subplot(311) plot(Wz,20*log10(abs(Hz)),'r'); axis ([0 pi ]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',-100:20:20) set(gca,'YTickLabel',{'-100','-80','-60','-40','-20','0','20'}) xlabel('Frequency (Hz)'), ylabel('Magnitude (dB)'); title('Log Magnitude Response '); subplot(312) plot(Wz,(abs(Hz)),'r'); axis ([0 pi ]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0.99:0.005:1.01) set(gca,'YTickLabel',{'0.99','0.995','1.0','1.005','1.01'}) xlabel('Frequency (Hz)'), ylabel('Magnitude '); title('Magnitude Response '); subplot(313) plot(Wz,(grpdelay(bz,az,Wz)),'r'); axis ([0 pi 0 25]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0:5:25) set(gca,'YTickLabel',{'0','5','10','15','20','25'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay '); Program of Ex.7.5 by Bilinear Transformation
94 Program of Ex.7.5 by Bilinear Transformation Chebyshev I 型 Frequency response
95 Program of Ex.7.5 by Bilinear Transformation Chebyshev II 型 Frequency response
96 Program of Ex.7.4 直接用数字滤波器设计指令 % Chebyshev I 型 M 程序如下 clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); [n,wn]=cheb1ord (.4*pi/pi,0.6*pi/pi,rp,rs) [z,p,k]= cheby1(n,rp,wn); [sos,g] = zp2sos(z,p,k); Hd = dfilt.df2tsos(sos,g); h = fvtool(Hd) figure zplane(z,p,k) [bz,az]=zp2tf (z,p,k)
97 Program of Ex.7.4 直接用数字滤波器设计指令 % Chebyshev II 型 M 程序如下 clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); [n,wn]=cheb2ord (.4*pi/pi,0.6*pi/pi,rp,rs) [z,p,k]= cheby2(n,rs,wn); [sos,g] = zp2sos(z,p,k); Hd = dfilt.df2tsos(sos,g); h = fvtool(Hd) figure zplane(z,p,k) [bz,az]=zp2tf (z,p,k)
98 E elliptic filters Elliptic filter 1 Jacobian elliptic function
99 Example 7.6 Elliptic Approximation
100 Example 7.6 frequency response of Elliptic
101 Program of Ex.7.5 by Bilinear Transformation % Elliptic filter M 程序如下 clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); wap=2*Fs*tan(wp/2);was=2*Fs*tan(ws/2); [n,wn]=ellipord(wap,was,rp,rs,'s') [z,p,k]=ellipap(n,rp,rs); [bp,ap]=zp2tf(z,p,k) [bs,as]=lp2lp(bp,ap,wn) [bz,az]=bilinear(bs,as,Fs) %[bs,as] =ellip(n,rp,rs,wn,'s'); %[bz,az]=bilinear(bs,as,Fs)
102 [Hz,Wz] = freqz(bz,az,512); Hz=Hz*(1+e); subplot(311) plot(Wz,20*log10(abs(Hz)),'r'); axis ([0 pi ]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',-100:20:20) set(gca,'YTickLabel',{'-100','-80','-60','-40','-20','0','20'}) xlabel('Frequency (Hz)'), ylabel('Magnitude (dB)'); title('Log Magnitude Response '); subplot(312) plot(Wz,(abs(Hz)),'r'); axis ([0 pi ]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0.99:0.005:1.01) set(gca,'YTickLabel',{'0.99','0.995','1.0','1.005','1.01'}) xlabel('Frequency (Hz)'), ylabel('Magnitude '); title('Magnitude Response '); subplot(313) plot(Wz,(grpdelay(bz,az,Wz)),'r'); axis ([0 pi 0 25]) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) set(gca,'YTick',0:5:25) set(gca,'YTickLabel',{'0','5','10','15','20','25'}) xlabel('Frequency (Hz)'), ylabel('groupdelay '); title('groupdelay '); Program of Ex.7.5 by Bilinear Transformation
103 Program of Ex.7.5 by Bilinear Transformation Elliptic filter Frequency response
104 Program of Ex.7.4 直接用数字滤波器设计指令 % Elliptic filter M 程序如下 clear all; Fs=1; e=0.007 wp=.4*pi; rp=-20*log10(0.99*(1/(1+e))); ws=.6*pi ; rs=-20*log10(0.001*(1/(1+e))); [n,wn]=ellipord (.4*pi/pi,0.6*pi/pi,rp,rs) [z,p,k]= ellip(n,rp,rs,wn); [sos,g] = zp2sos(z,p,k); Hd = dfilt.df2tsos(sos,g); h = fvtool(Hd) figure zplane(z,p,k) [bz,az]=zp2tf (z,p,k)
105 *Comparison of Butterworth, Chebyshev, elliptic filters: Example -Given specification -Order Butterworth Filter : N=14. ( max flat) Chebyshev Filter : N=8. ( Cheby 1, Cheby 2) Elliptic Filter : N=6 ( equiripple) B C E
106 -Pole-zero plot (analog) -Pole-zero plot (digital) BC1C2E BC1C2E (14)(8)
107 -Magnitude -Group delay B C1 C2 E B C1 C2 E
Design of FIR Filters by Windowing FIR filters are designed based on directly approximating the desired frequency response of the discrete- time system. Most techniques for approximating the magnitude response of an FIR system assume a linear phase constraint.
109 Window Method An ideal desired frequency response Many idealized systems are defined by piecewise-constant frequency response with discontinuities at the boundaries. As a result, these systems have impulse responses that are noncausal and infinitely long.
110 Window Method The most straightforward approach to obtaining a causal FIR approximation is to truncate the ideal impulse response.
111 Windowing in Frequency Domain Windowed frequency response The windowed version is smeared version of desired response
112 Window Method If
113 Choice of Window is as short as possible in duration. This minimizes computation in the implementation of the filter. approximates an impulse.
114 Window Method then would look like, except where changes very abruptly. If is chosen so that is concentrated in a narrow band of frequencies around
115 Rectangular Window for the rectangular window has a generalized linear phase. As M increases, the width of the “main lobe” decreases. While the width of each lobe decreases with M, the peak amplitudes of the main lobe and the side lobes grow such that the area under each lobe is a constant.
116 Rectangular Window will oscillate at the discontinuity. The oscillations occur more rapidly, but do not decrease in magnitude as M increases. The Gibbs phenomenon can be moderated through the use of a less abrupt truncation of the Fourier series.
117 Rectangular Window The Gibbs phenomenon can be moderated through the use of a less abrupt truncation of the Fourier series.
118 Rectangular Window By tapering the window smoothly to zero at each end, the height of the side lobes can be diminished. The expense is a wider main lobe and thus a wider transition at the discontinuity. 主瓣
Design of FIR Filters by Windowing Method To design an ilowpass FIR Filters Review
Properties of Commonly Used Windows Rectangular Bartlett (triangular) M-1 non zero values
Properties of Commonly Used Windows Hanning Hamming
Properties of Commonly Used Windows Blackman
Properties of Commonly Used Windows
124 Frequency Spectrum of Windows (a)-(e) attenuation of sidelobe increases, width of mainlobe increases. Rectangular Bartlett (triangular) Hanning Hamming Blackman 主瓣
Properties of Commonly Used Windows biggest , high oscillations at discontinuity smallest , the sharpest transition Table 7.1 主瓣 宽度 边瓣幅值
Incorporation of Generalized Linear Phase In designing FIR filters, it is desirable to obtain causal systems with a generalized linear phase response. The above five windows are all symmetric about the point,i.e.,
Incorporation of Generalized Linear Phase Their Fourier transforms are of the form
Incorporation of Generalized Linear Phase
129 Frequency Domain Representation
130 Ex. 7.7 design Linear-Phase Lowpass Filter The desired frequency response is Solution:
131 magnitude frequency response
Properties of Commonly Used Windows smallest , the sharpest transition biggest , high oscillations at discontinuity
The Kaiser Window Filter Design Method Trade side-lobe amplitude for main-lobe width
134 Figure 7.24 As increases, attenuation of sidelobe increases, width of mainlobe increases. As M increases, attenuation of sidelobe is preserved, width of mainlobe decreases. M=20 (a) Window shape, M=20, (b) Frequency spectrum, M=20, (c) beta=6 =6 (a) (b) (c)
135 Increasing M wile holding constant causes the main lobe to decrease in width, but does not affect the amplitude of the side lobe. Comparison If the window is tapered more, the side lobe of the Fourier transform become smaller, but the main lobe become wider. M=20 =6 M=20
136 Table 7.1 Transition width is a little less than mainlobe width
137 Filter Design by Kaiser Window
138 Filter Design by Kaiser Window M=20
139 Example 7.8 Kaiser Window Design of a Lowpass Filter Solution: scheme, To get need
140 Ex. 7.8 Kaiser Window Design of a Lowpass Filter
141 Example 7.8 Kaiser Window Design of a Lowpass Filter
142 Ex. 7.8 Kaiser Window Design of a Lowpass Filter
143 Ex. 7.8 Kaiser Window Design of a Lowpass Filter clear all; clc; close all wp=0.4*pi; ws=0.6*pi; wdelta=ws-wp; Wn=(wp+ws)/2; b=fir1(37,Wn/pi, kaiser(38,5.653)); [H,w]=freqz(b,1,2048) ; A(1:ceil(0.4*2048))=1-abs(H(1:ceil(0.4*2048))); A(floor(0.6*2048)-1:2048)=-abs(H(floor(0.6*2048)- 1:2048)); A(round(0.4*2048)+1:floor(0.6*2048)-1)=nan; subplot(311) stem(b) subplot(312) plot(w,20*log10(abs(H))) axis([0,pi,-100,20]); subplot(313) plot(w,A) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π' }) axis([0,pi,-0.001,0.001]);
Examples of FIR Filters Design by the Kaiser Window Method The ideal highpass filter with generalized linear phase
145 Example 7.9 Kaiser Window Design of a Highpass Filter Specifications: By Kaiser window method
146 Example 7.9 Kaiser Window Design of a Highpass Filter Specifications: By Kaiser window method
Discrete-Time Differentiator
148 Example 7.10 Kaiser Window Design of a Differentiator Since kaiser’s formulas were developed for frequency responses with simple magnitude discontinuities, it is not straightforward to apply them to differentiators. Suppose
149 Group Delay Phase: Group Delay:
150 Group Delay Phase: Group Delay: Noninteger delay
Optimum Approximations of FIR Filters Goal: Design a ‘best’ filter for a given M In designing a causal type I linear phase FIR filter, it is convenient first to consider the design of a zero phase filter. Then insert a delay sufficient to make it causal.
Optimum Approximations of FIR Filters
Optimum Approximations of FIR Filters Designing a filter to meet these specifications is to find the (L+1) impulse response values In Packs-McClellan algorithm, is fixed, and is variable. Packs-McClellan algorithm is the dominant method for optimum design of FIR filters.
Optimum Approximations of FIR Filters
Optimum Approximations of FIR Filters
Optimum Approximations of FIR Filters
157 Minimax criterion Within the frequency interval of the passband and stopband, we seek a frequency response that minimizes the maximum weighted approximation error of
158 Other criterions
159 Let denote the closet subset consisting of the disjoint union of closed subsets of the real axis x. Alternation Theorem is an r th-order polynomial. denotes a given desired function of x that is continuous on is a positive function, continuous on The weighted error is The maximum error is defined as
160 Alternation Theorem A necessary and sufficient condition that be the unique rth-order polynomial that minimizes is that exhibit at least (r+2) alternations; i.e., there must exist at least (r+2) values in such that and such that for
161 Example 7.11 Alternation Theorem and Polynomials Each of these polynomials is of fifth order. The closed subsets of the real axis x referred to in the theorem are the regions
Optimal Type I Lowpass Filters For Type I lowpass filter The desired lowpass frequency response Weighting function
Optimal Type I Lowpass Filters The weighted approximation error is The closed subset is or
Optimal Type I Lowpass Filters The alternation theorem states that a set of coefficients will correspond to the filter representing the unique best approximation to the ideal lowpass filter with the ratio fixed at K and with passband and stopband edge and if and only if exhibits at least (L+2) alternations on, i.e., if and only if alternately equals plus and minus its maximum value at least (L+2) times. Such approximations are called equiripple approximations.
Optimal Type I Lowpass Filters The alternation theorem states that the optimum filter must have a minimum of (L+2) alternations, but does not exclude the possibility of more than (L+2) alternations. In fact, for a lowpass filter, the maximum possible number of alternations is (L+3).
Optimal Type I Lowpass Filters Because all of the filters satisfy the alternation theorem for L=7 and for the same value of, it follows that and/or must be different for each,since the alternation theorem states that the optimum filter under the conditions of the theorem is unique.
167 Property for type I lowpass filters from the alternation theorem The maximum possible number of alternations of the error is (L+3) Alternations will always occur at and All points with zero slop inside the passband and all points with zero slop inside stopband will correspond to alternations; i.e., the filter will be equiripple, except possibly at and
Optimal Type II Lowpass Filters For Type II causal FIR filter: The filter length (M+1) is even, ie, M is odd Impulse response is symmetric The frequency response is
Optimal Type II Lowpass Filters
Optimal Type II Lowpass Filters For Type II lowpass filter,
The Park-McClellan Algorithm From the alternation theorem, the optimum filter will satisfy the set of equation
The Park-McClellan Algorithm Guessing a set of alternation frequencies and
The Park-McClellan Algorithm
The Park-McClellan Algorithm For equiripple lowpass approximation Filter length: (M+1)
Examples of FIR Equiripple Approximation Lowpass Filter
176 Comments M=26, Type I filter The minimum number of alternations is (L+2)=(M/2+2)=15 7 alternations in passband and 8 alternations in stopband The maximum error in passband and stopband are and , which exceed the specifications.
Lowpass Filter M=27,, Type II filter, zero at z=-1 The maximum error in passband and stopband are and , which exceed the specifications. The minimum number of alternations is (L+2)=(M-1)/2+2=15 7 alternations in passband and 8 alternations in stopband
178 Comparison Kaiser window method require M=38 to meet or exceed the specifications. Park-McClellan method require M=27 Window method produce approximately equal maximum error in passband and stopband. Park-McClellan method can weight the error differently.
Comments on IIR and FIR Discrete-Time Filters What type of system is best, IIR or FIR? Why give so many different design methods? Which method yields the best result?
Comments on IIR and FIR Discrete-Time Filters Closed- Form Formulas Generalized Linear Phase Order IIRYesNoLow FIRNoYesHigh
Properties of Commonly Used Windows Their Fourier transforms are concentrated around They have a simple functional form that allows them to be computed easily. The Fourier transform of the Bartlett window can be expressed as a product of Fourier transforms of rectangular windows. The Fourier transforms of the other windows can be expressed as sums of frequency-shifted Fourier transforms of rectangular windows.(Problem7.34)
182 Homework Simulate the frequency response (magnitude and phase) for Rectangular, Bartlett, Hanning, Hamming, and Blackman window with M=21 and M=51
Zhongguo Liu_Biomedical Engineering_Shandong Univ. Chapter 5 HW 7.2, 7.4, 7.15, 上一页下一页 返 回