假设我们一个接一个地应用了3个过滤器:
b, a = iirfilter(...) # or bilinear(...) or anything else producing b, a
y = lfilter(b, a, x)
b, a = iirfilter(...)
y = lfilter(b, a, y)
b, a = iirfilter(...)
y = lfilter(b, a, y)
如何得到与3个滤波器等价的系数b2
,a2
,这样我们只需一次lfilter
就可以得到结果:
?
编辑:卷积似乎不起作用:
fs = 44100
b2, a2 = iirfilter(2, 2.0/fs * np.asarray([40, 60]), btype='bandstop') # 50 hz reject
b3, a3 = iirfilter(2, 2.0/fs * np.asarray([85, 115]), btype='bandstop') # 100 hz reject
b = np.convolve(b2, b3)
a = np.convolve(a2, a3)
w, h = signal.freqz(b, a, worN=10000)
给出:
我尝试使用same
,full
,valid
参数np.卷积但他们都没能解决问题。在
见https://dsp.stackexchange.com/questions/38675/how-to-plot-magnitude-and-phase-response-of-2-cascaded-filters-in-matlab
你可以把分子和分母分开卷积
例如,您的采样率太高,并且复合滤波器的阶数不够长,无法对接近的空值给出那个么多的拒绝。降低采样率,然后向上插值44.1 kHz。在
以下是采样率降至4410赫兹的结果。在
^{pr2}$然后将IIR滤波器的输出通过10x插值滤波器,使采样率恢复到44.1khz。在
或者,减少过滤顺序:
以44.1 kHz的原始采样率产生
相关问题 更多 >
编程相关推荐