我正在尝试从此问题实现jsanalytics描述的过滤器: How to apply a Zero-Phase filter using MathDotNet library?
我只是复制了代码并添加了PI,但是在低通滤波器的末尾却得到了很多数字,并且“零相位”看起来不像原始问题的结果。
这是我来自jsanalytics的代码
//signal + noise
double pi = Math.PI;
double fs = 1000; //sampling rate
double fw = 5; //signal frequency
double n = 5; //number of periods to show
double A = 10; //signal amplitude
double N = 2; //noise amplitude
int size = (int)(n * fs / fw); //sample size
var t = Enumerable.Range(1, size).Select(p => p * 1 / fs).ToArray();
var noise = new WhiteGaussianNoiseSource();
var y = t.Select(p => (A * Math.Sin(2 * pi * fw * p)) + (N * noise.ReadNextSample())).ToArray();
//filter
double fc = 10; //cutoff frequency
var filter = OnlineFirFilter.CreateLowpass(ImpulseResponse.Finite, fs, fc);
double[] yf1 = filter.ProcessSamples(y); //Lowpass
double[] yf2 = filter.ProcessSamples(yf1.Reverse().ToArray()); //Lowpass reversed
double[] yf2r = yf2.Reverse().ToArray(); //Zero-Phase