所以你试图实现一个低通数字滤波器,它可以从.wav文件切换5000 hz以上的所有频率,它的采样率= 38000
所以我使用signal.butter来获得系数
但当我的功能添加6000的频率时,它不会过滤它,实际上它开始从15000赫兹过滤
谁能知道原因在哪里
from scipy import signal
nyq =0.5 *38000
b, a = signal.butter(5,5000/nyq, btype='low', analog=False, output='ba')
def browse_txt(self):
filepath = QtGui.QFileDialog.getOpenFileName(self, 'Single File', "C:\Users\Hanna Nabil\Desktop",'*.txt')
y=[0,0,0,0,0,0]
x=[0,0,0,0,0,0]
with open(filepath, "r") as f:
content = f.readlines()
content = [s.strip() for s in content]
print len(content)
index = 0
p=[]
while index < len(content):
x[0] = x[1]
x[1] = x[2]
x[2] = x[3]
x[3] = x[4]
x[4] = x[5]
x[5] = float(content[index])
y[0] = y[1]
y[1] = y[2]
y[2] = y[3]
y[3] = y[4]
y[4] = y[5]
#x = float(content[index])
y[5] =0.00405468* x[5] + 0.0202734 * x[4] +0.0405468 * x[3] + 0.0405468 * x[2] +0.0202734* x[1] + 0.00405468 * x[0]
- (-2.34299118)*y [4]- 2.58241136*y[3] -(-1.5249425)*y[2] -0.47760386 *y[1]- (-0.06233179)*y[0]
#p0 = float(content[index])
p.append(y[5])
index += 1
self.signal=np.array(p)
self.time = np.linspace(0, 1, 38000 * 1)
freq = fftfreq(self.signal.size, 1.0/38000)
self.xfourier =freq[:int(len(freq) / 2)]
mag= abs(fft(self.signal))
self.yfourier = mag[:int(len(mag) / 2)]
self.drawOn1()
self.drawOn3()