Closed rclai closed 8 years ago
Hi, after a little digging into matlab manuals, I guess, I found some differences. What fili designs is a one biquad butterworth filter. A biquad is always a two stage filter. fili works with cascades of two stage filters. Another difference is that the cutoff frequencies do not match. fili gets the sampling and the cutoff frequency in Hz. So, your filter expects a 256 Hz signal and implements a high pass at 0,000007Hz. This will never do something that makes any sense. Getting close to 0 or fs/2 will make filters unstable, especially if the filter order is low. The matlab implementation on the other hand produces a 1 stage butterworth filter with a cutoff frequency of 0,000007% of the nyquist frequency. For a 256Hz signal this would be 0,0000039Hz. This filter will also behave quite strange.
Thanks for taking the time to look at this.
If you're up for further discussion, I believe it is intentional for the filter to make values close to zero. To get a better idea of what I'm doing, I am filtering out the influence of gravity on accelerometer readings. I'm essentially trying to replicate this section of code that simply tries to detect stationary periods from acceleration data. Does this make sense?
No problem.
I see why you are setting the cutoff frequency close to 0. When calculating in double precision this may work. However, it will lead to results that differ by many ppm from the actual value due to rounding errors. I am responsible for the development of high precision measurement devices (weight, force, torque etc.) where this would not be acceptable. Implementing these filters as fixed point or single precision filters in an FPGA or microcontroller will also not work.
Your code snipped devides the signal spectrum into a low pass and a high pass part. Now it depends on what your latency requirements and processing power how you can implement that.
Hello, I'm trying to convert this little MATLAB snippet in hopes of being able to produce the same result on your library:
butter
documentationfiltfilt
documentationMy Fili code:
I am running this filter against a dataset that looks like this:
And after filtering it in MATLAB, I'm supposed to get this:
But after filtering it with my Fili code, I am getting this:
Would you happen to know where I went wrong?