Biomedical Signal processing Chapter 7 Filter Design Techniques 2018年11月29日6时3分 Biomedical Signal processing Chapter 7 Filter Design Techniques Zhongguo Liu Biomedical Engineering School of Control Science and Engineering, Shandong University 山东省精品课程《生物医学信号处理(双语)》 http://course.sdu.edu.cn/bdsp.html 2018/11/29 1 Zhongguo Liu_Biomedical Engineering_Shandong Univ.
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
Filter Design Techniques 7.0 Introduction
2018年11月29日6时3分 7.0 Introduction Frequency-selective filters pass only certain frequencies Any discrete-time system that modifies certain frequencies is called a filter. We concentrate on design of causal Frequency-selective filters
Linear time-invariant discrete-time system If input is bandlimited and sampling frequency is high enough to avoid aliasing, then overall system behaves as an LTI continuous-time system effective continuous-time specifications are converted to discrete time specifications by:
Stages of Filter Design Determine the specification of the desired properties of the system. The approximation of the specifications using(designing) a causal discrete-time system. The realization of the system. Our focus is on second step Specifications are typically given in the frequency domain.
Frequency-Selective Filters Ideal lowpass filter (discrete-time system)
Frequency-Selective Filters Ideal highpass filter(discrete-time system)
Frequency-Selective Filters Ideal bandpass filter(discrete-time system)
Frequency-Selective Filters Ideal bandstop filter(discrete-time system)
tolerance scheme 容限图 Figure depicts the typical representation of the tolerance limits associated with approximating an ideal lowpass filter. tolerance scheme 容限图 discrete-time continuous -time
Example 7.1 Determining Specifications for a Discrete-Time Filter H(ejw) . Known: Specifications of the continuous-time filter: 1. passband 2. stopband For bandlimited input, aliasing avoided when sampling frequency is high enough
Example 7.1 Determining Specifications for a Discrete-Time Filter Specifications of the continuous-time filter: 1. passband 2. stopband tolerance scheme 容限图
Example 7.1 Determining Specifications for a Discrete-Time Filter Solution: Specifications of the discrete-time filter in Same tolerance limits:
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.
Filter Design Techniques 7.1 Design of Discrete-Time IIR Filters From Continuous-Time Filters
7.1 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: Impulse Invariance, Bilinear transformation
Three Reasons The art of continuous-time IIR filter design is highly advanced, and useful results can be achieved, it is advantageous to use the design procedures already developed for continuous-time filters.
Three Reasons Many useful continuous-time IIR design method have relatively simple closed form design formulas. Therefore, discrete-time IIR filter design methods based on standard continuous-time design formulas are rather simple to carry out.
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.
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.
H(s)极点分布与原函数的对应关系(稳定性) 几种典型情况 p211
Constraints of Transformation In transformations, 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.
Constraints of Transformation In order to preserve the property of stability, If the continuous system has poles only in the left half of the s-plane, then the discrete- time filter must have poles only inside the unit circle.
7.1.1 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 between two systems: i.e. the continuous-time filter is bandlimited, and Ωs >2Ωmax in one period
relation between frequencies Relationship between two systems: S plane Z plane - No Aliasing one period
No Aliasing in the Impulse Invariance
Aliasing in the Impulse Invariance
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.
① Transformation of specifications from discrete to continuous In impulse invariance design procedure, assuming the aliasing in transformation is neglected, relation of specifications in transformation is
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.
② Find Continuous-time IIR filters Butterworth filters Chebyshev Type I filters Chebyshev Type II filters Elliptic filters
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.
③ Transformation from continuous to discrete Laplace Transform impulse invariance z-Transform
Ex. 7.2 design DT filter by Impulse Invariance with a Butterworth Filter Specifications for the discrete-time filter: Solution: ① Assume the effect of aliasing is negligible
Dependence of Butterworth magnitude characteristics on the order N. ② Butterworth Filter monotonic function of frequency magnitude-squared function Dependence of Butterworth magnitude characteristics on the order N.
Example 7.2 Impulse Invariance with a Butterworth Filter monotonic function of frequency
Example 7.2 Impulse Invariance with a Butterworth Filter round N up to passband specifications met exactly stopband specifications exceeded. allows some margin for aliasing
Example 7.2 Impulse Invariance with a Butterworth Filter Plole pairs: Left half of the s-plane
Example 7.2 Impulse Invariance with a Butterworth Filter Plole pairs: Left half of the s-plane
Example 7.2 Impulse Invariance with a Butterworth Filter Plole pairs:
Example 7.2 ③ Ak, Sk same as Td=1 same as Td=1
Example 7.2 Impulse Invariance with a Butterworth Filter Frequency response of 6th-order Butterworth filter Log magnitude in dB Magnitude Group delay
Program of Ex.7.2 using Impulse Invariance clear all; wp=.2*pi; rp=-20*log10(0.89125); ws=.3*pi; rs=-20*log10(0.17783); 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) %[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'); Butterworth analog lowpass filter prototype
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 -100 20]) 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,'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,'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.2 using Impulse Invariance [Hz,Wz] = freqz(bz,az,512); ....... 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,'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.2 using Impulse Invariance Log magnitude in dB Magnitude Group delay
summary for Impulse Invariance The basis for Impulse Invariance is to choose an impulse response for the DT-filter that is similar in some sense to the impulse response of the CT-filter. If the CT filter is bandlimited, then the DT filter frequency response will closely approximate the CT filter frequency response.
summary for Impulse Invariance The relationship between CT and DT frequency is linear; consequently, except for aliasing, the shape of the frequency response is preserved.
summary for Impulse Invariance The relationship between CT and DT frequency is linear; consequently, except for aliasing, the shape of the frequency response is preserved.
7.1.2 Bilinear Transformation Bilinear transformation can avoid the problem of aliasing. Bilinear transformation maps onto Bilinear transformation:
7.1.2 Bilinear Transformation
7.1.2 Bilinear Transformation
7.1.2 Bilinear Transformation Derivation (textbook): relationship between w and Ω
relation between frequency response for CT, DT filter 2018年11月29日6时3分 relation between frequency response for CT, DT filter Same tolerance limit for Passband, stopband
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
Comments on the Bilinear Transformation 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.
Bilinear Transformation of distortion in the frequency axis also manifests warping of the phase response of the filter
Comparisons of Impulse Invariance and Bilinear Transformation The use of bilinear transformation is restricted to the design of approximations to filters with piecewise-constant magnitude-response characteristics, such as highpass, lowpass and bandpass filters. Impulse invariance can be used to design lowpass filters. However, it cannot be used to map highpass CT designs to highpass DT designs because they are not bandlimited.
Comparisons of Impulse Invariance and Bilinear Transformation Bilinear transformation cannot design filter whose magnitude-response isn’t piecewise constant, like differentiator. However, Impulse invariance can design an bandlimited differentiator.
7.1.3 Examples of Bilinear Transformation Example 7.3 is to illustrate the steps in the design of a Butterworth filter using the bilinear transformation. Example 7.4, 7.5 , 7.6 illustrate design of: Butterworth Filter; Chebyshev (I, II) Approximation; Elliptic Approximation
Bilinear Transformation of a Butterworth Filter Ex.7.3 Design DT filter, given specification: Solution: (1) CT fiter spec, (prewarp)
Ex.7.3 Bilinear Transformation: Butterworth Filter passband specifications exceeded. stopband specifications met exactly (2) Butterworth Filter
Example 7.2 Impulse Invariance with a Butterworth Filter Plole pairs: Left half of the s-plane
Example 7.3 Bilinear Transformation of a Butterworth Filter Plole pairs: (3) same as
Ex. 7.3 frequency response of DT filter Log magnitude in dB Magnitude Group delay
Program of Ex.7.3 by Bilinear Transformation clear all; wp=.2*pi; rp=-20*log10(0.89125); ws=.3*pi; rs=-20*log10(0.17783); 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) %[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'); Butterworth analog lowpass filter prototype [n,Wn]=buttord(.2*pi/pi,0.3*pi/pi,rp,rs) % no 's‘! [bs,as] = butter(n,wn);
Program of Ex.7.3 by Bilinear Transformation [Hz,Wz] = freqz(bz,az,512); subplot(311) plot(Wz,20*log10(abs(Hz)),'r');grid on axis ([0 pi -100 20]) 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,'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,'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 Log magnitude in dB Magnitude Group delay
Program of Ex.7.3直接用数字滤波器设计指令 clear all; Fs=1 wp=.2*pi; rp=-20*log10(0.89125); ws=.3*pi; rs=-20*log10(0.17783); [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 ([0 0.15 -20 0]) figure zplane(bz,az) [z,p,k]=tf2zp(bz,az) zplane(z,p,k)
7.1.3 Examples of Bilinear Transformation Butterworth Filter, Chebyshev Approximation, I, II Elliptic Approximation Example7.4, 7.5, 7.6 Design DT filter, given specification:
Example 7.4 Butterworth Approximation CT filter specification
Example 7.4 frequency response Log magnitude in dB Magnitude in passband only Group delay
Example 7.4 frequency response 1.007 Magnitude in passband only passband edge frequency 0.99 passband stopband 0.983
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) % [bs,as] = butter(n,wn,'s'); [bz,az]=bilinear(bs,as,Fs) bz=bz *(1+e); [Hz,Wz] = freqz(bz,az,512); % Hz=Hz*(1+e);
Program of Ex.7.4 by Bilinear Transformation [Hz,Wz] = freqz(bz,az,512); % Hz=Hz*(1+e); subplot(311) plot(Wz,20*log10(abs(Hz)),'r'); axis ([0 pi -100 20]) 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.99 1.01]) 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,'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 Log magnitude in dB Frequency response Magnitude Group delay
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, .6*pi/pi,rp,rs) % no's'! [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)
Chebyshev filter (type I) Chebyshev filters Chebyshev filter (type I) 双曲余弦 Chebyshev polynomial N=0, V0(x)=1; N=1, V1(x)=cos(cos-1x)= x; N=2, V2(x)=cos(2cos-1x) =2x2-1; N=3, V3(x)=4x3-3x VN+1(x)=2xVN(x) - VN-l(x)
Chebyshev filter (type I) Chebyshev filters Chebyshev filter (type I) 双曲余弦 Chebyshev polynomial
Chebyshev filter (type I) Chebyshev filters Chebyshev filter (type I) Chebyshev polynomial x
Ws is stopband cut-off frequency Three parameters of Chebyshev filter: Wc :given passband cut-off frequency e :is specified by the allowable passband ripple 由通带衰减(passband attenuation)决定 N:filter order, 等于通带内最大最小值的总数 Ws is stopband cut-off frequency 阻带衰减越大所需阶数越高
Chebyshev低通滤波器幅度平方函数的极点分布 以上Ωc,ε和N确定后,可以求出滤波器的极点,并确定Ha(p),p=s/Ωc。 有用的结果:设Ha(s)的极点为si=σi+jΩi,可证明: 上式是一个椭圆方程,因为ch(x)大于sh(x),长半轴为Ωcchξ(在虚轴上),短半轴为Ωcshξ(在实轴上)。
令bΩc和aΩc分别表示长半轴和短半轴,可推导出: 设N=3,平方幅度函数的极点分布如图所示(极点用X表示)。为稳定,用左半平面的极点构成Ha(p),即
c是待定系数。根据幅度平方函数式可导出:c=ε·2N-1,代入上式,得到归一化的传输函数为 去归一化后的传输函数为 三阶切比雪夫滤波器的极点分布图
Chebyshev filters Chebyshev filter (type II) Chebyshev filter (type I) 1 Chebyshev filter (type I)
Example 7.5 Chebyshev Type I , II Approximation
Example 7.5 frequency response of Chebyshev Type I Type II Magnitude in passband only
Program of Ex.7.5 by Bilinear Transformation % Chebyshev I Matlab program: clear all; Fs=1; e=0.007(书图中最大幅值大约值1+e) 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) % [bs,as] = cheby1(n,rp,wn,'s'); [bz,az]=bilinear(bs,as,Fs) bz=bz *(1+e);
Program of Ex.7.5 by Bilinear Transformation % Chebyshev II Matlab program 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) %[bs,as] = cheby2(n,rs,wn,'s'); [bz,az]=bilinear(bs,as,Fs) bz=bz *(1+e); be careful !
Program of Ex.7.5 by Bilinear Transformation [Hz,Wz] = freqz(bz,az,512); %Hz=Hz*(1+e); subplot(311) plot(Wz,20*log10(abs(Hz)),'r'); axis ([0 pi -100 20]) 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.99 1.01]) 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,'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 Frequency response Chebyshev I型
Program of Ex.7.5 by Bilinear Transformation Log magnitude in dB Frequency response Chebyshev II型 Magnitude in passband Group delay
Program of Ex.7.5直接用数字滤波器设计指令 % 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); k=k*(1+e); [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)
Program of Ex.7.5直接用数字滤波器设计指令 % 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); k=k*(1+e); [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) zplane(bz,az)
elliptic filters 1 Elliptic filter Jacobian elliptic function
Example 7.6 Elliptic Approximation
Example 7.6 frequency response of Elliptic Log magnitude in dB Magnitude in passband Group delay
Program of Ex.7.6 by Bilinear Transformation % Elliptic filter M程序如下 clear all; Fs=1; e=0.005 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) %[bs,as] =ellip(n,rp,rs,wn,'s'); [bz,az]=bilinear(bs,as,Fs); bz=bz *(1+e);
Program of Ex.7.5 by Bilinear Transformation [Hz,Wz] = freqz(bz,az,512); %Hz=Hz*(1+e); subplot(311) plot(Wz,20*log10(abs(Hz)),'r'); axis ([0 pi -100 20]) 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.99 1.01]) 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,'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 Log magnitude in dB Frequency response Elliptic filter Magnitude in passband Group delay
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); k=k*(1+e); [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) zplane(bz,az)
Butterworth Filter : N=14. ( max flat) *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
-Pole-zero plot (analog) B C1 C2 E -Pole-zero plot (digital) B C1 C2 E (14) (8)
-Group delay -Magnitude C1 B B E C1 E C2 C2
7.2 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.
Window Method An ideal desired frequency response Many idealized systems have discontinuous piecewise-constant frequency response, and their impulse responses are noncausal and infinitely long.
Window Method The most straightforward approach for obtaining a causal FIR approximation is to truncate the ideal impulse response.
Windowing in Frequency Domain Windowed frequency response The windowed version is smeared version of desired response Gibbs phenomenon
Window Method If
Choice of Window is as short as possible in duration. This minimizes computation in the implementation of the filter. approximates an impulse.
Window Method If is chosen so that is concentrated in a narrow band of frequencies around then would look like , except where changes very abruptly.
Rectangular Window for the rectangular window has a generalized linear phase. As M increases, the width of the “main lobe” decreases.
will oscillate at the discontinuity. Rectangular Window will oscillate at the discontinuity. The oscillations occur more rapidly, but do not decrease in magnitude as M increases. Gibbs phenomenon
Rectangular Window In theory of Fourier series, this nonuniform convergence, the Gibbs phenomenon can be moderated through the use of less abrupt truncation of the Fourier series.
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. 主瓣
7.2.1 Properties of Commonly Used Windows Rectangular Bartlett (triangular) M-1 non zero values
7.2.1 Properties of Commonly Used Windows Hanning Hamming
7.2.1 Properties of Commonly Used Windows Blackman
7.2.1 Properties of Commonly Used Windows
主瓣 Hamming Blackman Rectangular Bartlett (triangular) Hanning Frequency Spectrum of Windows (a)-(e) attenuation of sidelobe increases, width of mainlobe increases.
7.2.1 Properties of Commonly Used Windows Table 7.1 边瓣幅值 主瓣 宽度 biggest,high oscillations at discontinuity smallest,the sharpest transition
7.2.2 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.,
7.2.2 Incorporation of Generalized Linear Phase Their Fourier transforms are of the form
7.2.2 Incorporation of Generalized Linear Phase 2018年11月29日6时3分 7.2.2 Incorporation of Generalized Linear Phase Hilbert filter hd[n]
Frequency Domain Representation Linear Phase
Ex. 7.7 design Linear-Phase Lowpass Filter The desired frequency response is verification Solution:
magnitude frequency response Example:design a FIR filter M
例7.7 matlab program for FIR Filter disign,specification: Solution: clc;clear all; close all wp=0.15*pi; ws=0.25*pi; wdelta=ws-wp; N=ceil(8*pi/wdelta); Wn=(0.15+0.25)*pi/2; b=fir1(N,Wn/pi,hanning(N+1)); figure % freqz(b,1,512) [H,w]=freqz(b,1,512) ; plot(w,abs(H)) set(gca,'XTick',0:0.2*pi:pi) set(gca,'XTickLabel',{'0','0.2π','0.4π','0.6π','0.8π','π'}) axis([0,pi,0.97,1.03]); Hanning窗
7.2 Design of FIR Filters by Windowing Method Review To design an lowpass FIR Filters
7.2.1 Properties of Commonly Used Windows smallest,the sharpest transition biggest,high oscillations at discontinuity
7.2.3 The Kaiser ['kaizə] Window Filter Design Method Caesar[ˈsi:zə] 凯撒 Trade side-lobe amplitude for main-lobe width
continuous envelopes of Kaiser windows (b) M=20 As increases, attenuation of sidelobe increases, width of mainlobe increases. =6 (c) As M increases, attenuation of sidelobe is preserved, width of mainlobe decreases. (a) Window shape, M=20 (b) Frequency spectrum, M=20, (c) beta=6 Figure 7.24
2018年11月29日6时3分 Comparison If the window is tapered more, the side lobe of the Fourier transform become smaller, but the main lobe become wider. Increasing M wile holding constant causes the main lobe to decrease in width, M=20 but does not affect the amplitude of the side lobe. =6 M=20
Transition width is a little less than mainlobe width Table 7.1 Comparison Of Commonly Used Windows- with Kaiser windows Transition width is a little less than mainlobe width
Filter Design by Kaiser Window (1) the specifications must be established : (2) (3) Peak approximation error Transition width To predict the values of M and β
Filter Design by Kaiser Window (3) (4) magnitude response validation, (5) linear phase, group delay .
Example 7.8 Kaiser Window Design of a Lowpass Filter analysis: to get need need
Ex. 7.8 Kaiser Window Design of a Lowpass Filter Solution:
Example 7.8 Kaiser Window Design of a Lowpass Filter
Ex. 7.8 Kaiser Window Design of a Lowpass Filter magnitude response validation, peak approximation error is δ=0.00113 instead of the desired value of 0.001. h[n]=[-0.0002 0.0005 0.0010 -0.0015 -0.0024 0.0034 0.0048 -0.0065 -0.0088 0.0115 0.0150 -0.0194 -0.0250 0.0325 0.0429 -0.0586 -0.0859 0.1475 0.4492 0.4492 0.1475 -0.0859 -0.0586 0.0429 0.0325 -0.0250 -0.0194 0.0150 0.0115 -0.0088 -0.0065 0.0048 0.0034 -0.0024 -0.0015 0.0010 0.0005 -0.0002 ] In this case it is necessary to increase M to 38 in order to meet the specifications. phase response
Ex. 7.8 Kaiser Window Design of a Lowpass Filter clear all; clc; wp=0.4*pi; ws=0.6*pi; Wn=(wp+ws)/2; b=fir1(37,Wn/pi, kaiser(38,5.653)); fcuts = [wp/pi ws/pi]; mags = [1 0]; devs = [0.01 0.001]; [n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs); b= fir1(n,Wn,ftype,kaiser(n+1,beta)); [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]);
7.3 Examples of FIR Filters Design by the Kaiser Window Method The ideal highpass filter with generalized linear phase
Example 7.9 Kaiser Window Design of a Highpass Filter Specifications: By Kaiser window method
Ex. 7.8 Kaiser Window Design of a Lowpass Filter clear all; clc; wp=0.5*pi; ws=0.35*pi; fcuts = [ws/pi wp/pi]; mags = [0 1]; devs = [0.021 0.021]; [n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs); b=fir1(n,Wn,ftype,kaiser(n+1,beta)); [H,w]=freqz(b,1,2048) ; A(1:ceil(ws/pi*2048))=-abs(H(1:ceil(ws/pi*2048))); A(floor(wp/pi*2048)-1:2048)=1-abs(H(floor(wp/pi*2048)-1:2048)); A(round(ws/pi*2048)+1:floor(wp/pi*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.025,0.025]); n =24, beta =2.5974
7.3.2 Discrete-Time Differentiator M=10,even Type III M=5,odd Type IV
Example 7.10 Kaiser Window Design of a Differentiator Suppose Ideal Impulse response Kaiser window type III FIR differentiator. Impulse response
Example 7.10 Kaiser Window Design of a Differentiator Suppose Magnitude response Approximation error for A0(ejW ).
Example 7.10 Kaiser Window Design of a Differentiator Suppose Ideal Impulse response Kaiser window type IV FIR differentiator. Impulse response
Example 7.10 Kaiser Window Design of a Differentiator Suppose Magnitude response Approximation error for A0(ejW ).
Group Delay Phase: Group Delay: Noninteger delay
7.4 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.
7.4 Optimum Approximations of FIR Filters zero phase filter
7.4 Optimum Approximations of FIR Filters Designing a filter to meet these specifications is to find the (L+1) impulse response values Packs-McClellan algorithm is the dominant method for optimum design of FIR filters. In Packs-McClellan algorithm, is fixed, and is variable.
7.4 Optimum Approximations of FIR Filters
7.4 Optimum Approximations of FIR Filters
7.4 Optimum Approximations of FIR Filters
Minimax criterion Within the frequency interval of the passband and stopband, we seek a frequency response that minimizes the maximum weighted approximation error of
Other criterions
Alternation Theorem Let denote the closed subset consisting of the disjoint union of closed subsets of the real axis x. 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
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
Example 7.11 Alternation Theorem and Polynomials suppose Each of these polynomials is of fifth order.
Example 7.11 Alternation Theorem and Polynomials The closed subsets of the real axis x referred to in the theorem are the regions P3(x) is the unique optimal 5th-order polynomial approximation for this region.
7.4.1 Optimal Type I Lowpass Filters For Type I lowpass filter The desired lowpass frequency response Weighting function
7.4.1 Optimal Type I Lowpass Filters The weighted approximation error is The closed subset is or
7.4.1 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 ;
7.4.1 Optimal Type I Lowpass Filters 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.
7.4.1 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).
7.4.1 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.
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 slope inside the passband and all points with zero slope inside stopband will correspond to alternations; i.e., the filter will be equiripple, except possibly at and
7.4.2 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
7.4.2 Optimal Type II Lowpass Filters
7.4.2 Optimal Type II Lowpass Filters For Type II lowpass filter,
7.4.3 The Park-McClellan Algorithm From the alternation theorem, the optimum filter will satisfy the set of equation
7.4.3 The Park-McClellan Algorithm Guessing a set of alternation frequencies and
7.4.3 The Park-McClellan Algorithm
7.4.3 The Park-McClellan Algorithm For equiripple lowpass approximation Filter length: (M+1)
7.5 Examples of FIR Equiripple Approximation 7.5.1 Lowpass Filter
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 0.0116 and 0.0016, which exceed the specifications.
M=27, Type II filter, zero at z=-1 7.5.1 Lowpass Filter M=27, Type II filter, zero at z=-1 The maximum error in passband and stopband are 0.0092 and 0.00092, 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
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.
7.6 Comments on IIR and FIR Discrete-Time Filters What type of system is best, IIR or FIR? IIR: closed-form design formulas straightforward noniterative computer programs for IIR filter design. 一次设计,指标要求满足 FIR: can have a (generalized) linear phase iteration may be necessary to meet a prescribed specification. 一次设计,未必满足指标要求
7.6 Comments on IIR and FIR Discrete-Time Filters Why give so many different design methods? Which method yields the best result? Closed-Form Formulas Generalized Linear Phase Order IIR Yes No Low FIR High
Zhongguo Liu_Biomedical Engineering_Shandong Univ. Chapter 5 HW 7.2, 7.4, 7.15, Zhongguo Liu_Biomedical Engineering_Shandong Univ. 199 2018/11/29 返 回 上一页 下一页