python 数字信号的滤波器设计 signal.buffer

来源:互联网 发布:医疗数据分析师 编辑:程序博客网 时间:2024/06/06 10:38

 python 中 对滤波器设计 可以用 signal模块下的buffer函数,其函数借口和matlab下的buffer很类似。

在网上找到了一篇关于matlab下的buffer函数,定义及案例的很好的文章,作为参考。


基于matlab的数字滤波器(butter函数)

http://blog.163.com/med_devices/blog/static/21997205020136134254451/



butter函数是求Butterworth数字滤波器的系数,在求出系数后对信号进行滤波时用filter函数。
说白了,设计滤波器就是设计滤波器系数[B,A]。

[B,A] = BUTTER(N,Wn) designs an Nth order lowpass digital Butterworth filter and returns the filter coefficients in length N+1 vectors B (numerator) and A (denominator).
[b,a]=butter(n,Wn),根据阶数n和归一化截止频率Wn计算ButterWorth滤波器分子分母系数(b为分子系数的矢量形式,a为分母系数的矢量形式)。

The cutoff frequency Wn must be 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.
Wn是归一化频率,具体计算方法是(2*截止频率)/采样频率(也就是除以fs/2)。

If Wn is a two-element vector, Wn = [W1 W2], BUTTER returns an order 2N bandpass filter with passband W1 < W < W2.
    [B,A] = BUTTER(N,Wn,'high') designs a highpass filter.高通滤波器
    [B,A] = BUTTER(N,Wn,'low') designs a lowpass filter.低通滤波器
    [B,A] = BUTTER(N,Wn,'stop') is a bandstop filter if Wn = [W1 W2].
    [B,A] = BUTTER(N,Wn)--带通滤波器
当设计低通和高通时,Wn是一个值,表示截止频率;
当设计带通和带阻时,Wn是一个二个元素的数组,表示通带或阻带的上下截止频率。频率的归一化是对fs/2进行归一。


也有简便的方法?

对于原始信号x。
比如说你的采样频率fs=1000Hz,设计一个8阶、通带为fc1=100,fc2=200Hz的带通滤波器:
[b,a]=butter(8,[0.2 0.4])=butter(8,fc1/fa fc2/fa])
这里fa=fs/2,fa是分析频率
得到滤波器系数后,就可以直接用了。
y=filter(B,A,x)




先写出这个文章,后面具体应用后,补充一篇应用文章。

原创粉丝点击