← Home

Chapter 09 · Design of Digital Filters

数字滤波器设计

Window-Method FIR Design

窗函数法设计 FIR 滤波器

FIR 设计的招牌方法:先写出理想滤波器的无限长冲激响应(一个 sinc),再乘一个有限长窗把它截成因果、可实现的 FIR。 对称的 自动给出严格线性相位。核心权衡在窗的选择上: 窗越平滑,阻带衰减越深(旁瓣越低),但过渡带越宽(主瓣越宽)。
The signature FIR method: take the ideal filter's infinite sinc impulse response, then multiply by a finite window to make it a causal FIR. A symmetric gives exactly linear phase. The window choice trades stopband depth against transition width.

Step 0: Design Target 技术指标

给四项指标:截止 (带通 / 带阻为两个 )、过渡带宽 、通带纹波 、阻带衰减 。它们在下方幅频图上规定了红色禁区;sandbox 的设计强制使用这里的截止,两者始终同步。 9.2 IIR 的指标含通带边 、阻带边 ,这里用等价写法:截止 (理想 sinc 的截止、过渡带中点)加过渡带宽 ,换算即得两条带边 。之所以这么写,是因为窗法的过渡带关于截止对称,且 直接决定长度 (窗主瓣宽 ),所以 是 FIR 更自然的参数。
FIR 窗法的特性:通带、阻带纹波由窗绑定(),所以 并非独立旋钮,设得过严会怎么加 都达不到(这正是与 IIR 的关键区别)。

0.30
0.16
1.0
40
The Design Sandbox
选窗、选类型、调长度与截止,看冲激响应被窗截断、看幅频响应成形
窗 Window
类型 Type
41
0.30
冲激响应:理想 (灰)× 窗(橙)= 实际 (蓝)
幅频响应
看两件事:左图里窗把 sinc 的两端平滑地压到零(矩形窗是硬截断,端点突变最大);右图里越平滑的窗 阻带压得越深、但过渡带越宽。把窗从矩形换到布莱克曼,阻带从约 dB 一路降到 dB,代价是过渡带变宽;想补回过渡带,就加大
The Window Tradeoff
五窗权衡:主瓣宽决定过渡带,旁瓣衰减决定阻带衰减(取自课件表)
窗 Window 主瓣宽 Mainlobe 峰值旁瓣 Peak sidelobe 加窗后阻带衰减 Stopband atten.
矩形Rectangular-13 dB-21 dB
三角Triangular-25 dB-25 dB
汉宁Hanning-31 dB-44 dB
汉明Hamming-41 dB-53 dB
布莱克曼Blackman-57 dB-74 dB
Kaiser可调 β可调随 β随 β(兼顾两者)
设计配方:先由阻带衰减 选窗(查上表);再由过渡带 定长度 ; 取 写理想 ;得 ;最后用 验证。 本页统一用一类线性相位(偶对称、N 奇),所以 LP/HP/BP/BS 四类都能做;HP/BP/BS 的理想响应等价于由低通组合而成。
Think About It 想一想
Q1: 为什么截断会产生 Gibbs 振荡?Why does truncation produce Gibbs ripple?

时域相乘等于频域卷积。理想砖墙 与窗的频谱 卷积,主瓣把陡边抹成过渡带,旁瓣在通带/阻带留下起伏,就是 Gibbs 振荡。矩形窗旁瓣最高( dB),所以振荡最大;越平滑的窗旁瓣越低,振荡越小。

Multiplying in time is convolution in frequency: the ideal brick wall is smeared by the window's spectrum. Its mainlobe widens the edge into a transition band; its sidelobes leave ripple, the Gibbs phenomenon. The rectangular window has the tallest sidelobes, hence the worst ripple.

同根同源:这正是 5.4 谱分析里"数学直观"讲的同一回事,时域乘窗 = 频域与窗谱卷积。区别只在被窗的对象:那里窗截断的是信号,后果是频谱泄漏(主瓣展宽、旁瓣抬起);这里窗截断的是滤波器的冲激响应,后果是过渡带(主瓣)与 Gibbs 纹波(旁瓣)。同一套主瓣 / 旁瓣机制,换了对象。→ 打开 5.4 谱分析的"数学直观"折叠卡

Same root as the "intuition" card in §5.4 spectral analysis: time-domain windowing is frequency-domain convolution with the window spectrum. There the window truncates a signal (spectral leakage); here it truncates the filter's impulse response (transition band from the mainlobe, Gibbs ripple from the sidelobes).

Q2: 主瓣和旁瓣分别决定什么?What do mainlobe and sidelobe each control?

主瓣宽度决定过渡带宽度:主瓣越宽,过渡带越缓;主瓣宽与 成反比,所以加大 能压窄过渡带。 旁瓣高度决定阻带衰减(与通带纹波):旁瓣越低,阻带越深。 关键在于:旁瓣高低只由窗的形状决定,几乎与 无关,所以加大 不会改善阻带衰减,只会变窄过渡带。要更深的阻带必须换窗

Mainlobe width sets the transition width and shrinks as N grows. Sidelobe height sets the stopband attenuation (and passband ripple) and depends on window shape, not N. So increasing N narrows the transition but does not deepen the stopband; for that you must change the window.

Q3: 为什么过渡带关于截止 对称?对任何窗都成立吗?Why is the transition symmetric about Ωc? For any window?

还是"时域乘窗 = 频域卷积":。在截止附近,理想砖墙就是一个阶跃,而阶跃卷一个核 = 核的累积积分。只要窗谱 实偶,就有恒等式 :过渡曲线关于点 反对称。于是 关于 对称(即 );同一条恒等式还顺带给出 ,正是"通带、阻带纹波由窗绑定"的根。

条件只有一个 实偶,它等价于窗在时域对称,也就是线性相位)。所有标准窗(矩形、三角、汉宁、汉明、布莱克曼、Kaiser)都对称,所以全都成立;只有非对称窗(罕见,如刻意做成最小相位的窗)才会破坏对称。另外这是"近边沿"的近似:当 太贴近 / ,或两条带边靠太近时,会有极小偏差。

The window method gives H = H_d * W. Near the edge the ideal wall is a step, and a step convolved with W is the running integral of W. If the window spectrum W is real and even, then H(Ωc+δ)+H(Ωc-δ)=1: the transition is point-symmetric about (Ωc, 1/2), so Ωp and Ωs sit symmetrically about Ωc (Ωc=(Ωp+Ωs)/2) and δp=δs. "W real and even" just means the window is symmetric in time (linear phase). All standard windows are symmetric, so it always holds; only an asymmetric window breaks it. It is a near-edge approximation, with tiny deviations when Ωc is very close to 0 or π.

Q4: 为什么低通、带阻必须 取奇数?Why must N be odd for LP and BS?

偶对称且 为偶数(二类线性相位)时,振幅响应在 恒为零),所以在 附近必须通过的高通、带阻做不了。要在 有非零增益,就得 奇(一类线性相位),它对 都偶对称,四类都能实现。详见 线性相位四类与可实现性

With even symmetry and even N, the amplitude response is forced to zero at Ω=π, so high-pass and band-stop (which must pass π) are impossible. Odd N (Type I) is even-symmetric about both Ω=0 and π, so all four types work. See the linear-phase bonus page.

Q5: MATLAB 里 做的就是这件事吗?Is this what MATLAB's fir1 does?

是。 正是"理想 乘窗",其中 是阶数, 是归一化截止(以 为单位), 是长度 的窗向量(默认汉明)。本页的曲线就是 的结果。频率采样法 与等波纹 是另外两条 FIR 设计路线。

Yes. fir1(M,Wc,'ftype',window) is exactly "ideal h_d times window," with M=N-1 the order, Wc the normalized cutoff (in units of π), and a length-(M+1) window vector (Hamming by default). fir2 (frequency sampling) and firpm (equiripple) are the other two FIR routes.