在matlab中有一个名为bandpass
的函数,我经常使用它。
函数的文档可以在这里找到:https://ch.mathworks.com/help/signal/ref/bandpass.html
我正在寻找一种在Python中应用带通滤波器并获得相同或几乎相同的输出滤波信号的方法
我的信号可以从这里下载:https://gofile.io/?c=JBGVsH
Matlab代码:
load('mysignal.mat')
y = bandpass(x, [0.015,0.15], 1/0.7);
plot(x);hold on; plot(y)
Python代码:
import matplotlib.pyplot as plt
import scipy.io
from scipy.signal import butter, lfilter
x = scipy.io.loadmat("mysignal.mat")['x']
def butter_bandpass(lowcut, highcut, fs, order=5):
nyq = 0.5 * fs
low = lowcut / nyq
high = highcut / nyq
b, a = butter(order, [low, high], btype='band')
return b, a
def butter_bandpass_filter(data, lowcut, highcut, fs, order=6):
b, a = butter_bandpass(lowcut, highcut, fs, order=order)
y = lfilter(b, a, data)
return y
y = butter_bandpass_filter(x, 0.015, 0.15, 1/0.7, order=6)
plt.plot(x);plt.plot(y);plt.show()
我需要在python中找到一种方法来应用类似于Matlab示例代码块中的过滤
目前没有回答
相关问题 更多 >
编程相关推荐