admin管理员组

文章数量:1289753

I'm learning on signal process and I'm trying to simulate a First-order low-pass filter as the equation below: (1+ω)y[n]=x[n]+ωy[n-1] where y[n] denotes the output and x[n] denotes input. So I try to use this filter with filtfilt to process a series of samples, the ω is 5:

import scipy.signal as signal
import matplotlib.pyplot as plt

b = [1]
a = [6, -5]
#loading origin-CH1 0.txt
x = []
with open("origin'-CH1 20.txt", 'r') as f:
    for line in f:
        x.append(float(line))
y = signal.filtfilt(b=b, a=a, x=x,method='gust')

#writing output to origin-CH1 0.txt
with open("origin'--CH1 0.txt", 'w') as f:
    for i in y:
        f.write(str(i) + '\n')

#plot
plt.plot(y, label="After Filter", color='red')
plt.plot(x, label="Before Filter", color='blue',alpha=0.5)
plt.show()

but the samples filtered seems innormal

You can see that there is a significant upward trend in the starting position of the filtered data, which is weird. I try to lower the value of ω, but it seems not quite useful. Why would this happen? If u need here is the origin samples origin'-CH1 20.txt

本文标签: