Initial and end artifacts after applying digital filter (filtfilt)
Show older comments
I need to filter highly noisy signals (at a sample rate of 2000 Hz).
When applying the code:
[b,a]=butter(order,Fcutoff/(2*Fs),'low');
f_signal=filtfilt(b,a,x);
Where:
order = 2; Fcutoff = 4Hz; Fs = 2000 Hz; x = Non filtered signal as a double vector;
The output filtered signals appear to have (only for some cases) and initial and end artifact, where they tend to deviate upwards or downwards (only at the edges of the filtered signal).
What is the data that is being processed by the filter at the edges?
How can I know how many data points are being used in this process?
Is there a clean way to tackle this problem?
1 Comment
Mathieu NOE
on 23 Oct 2020
hi
these artifacts are sometimes caused by the filtfilt function that do filtering in both direct and reverse time axis (so no phase lag)
try filter instead (this runs the signal only in the causal time direction, but you will get phase alg according to the low pass filter)
i see also that you are focusing on the very low frequency range , while your signal is sampled at 2000 Hz
I woud recommend to decimate your signal (this also apply a low pass filter) so if you have very long data, this will help you speed up your post processing
help decimate
DECIMATE Resample data at a lower rate after lowpass filtering.
Y = DECIMATE(X,R) resamples the sequence in vector X at 1/R times the
original sample rate. The resulting resampled vector Y is R times shorter,
LENGTH(Y) = LENGTH(X)/R.
DECIMATE filters the data with an eighth order Chebyshev Type I lowpass
filter with cutoff frequency .8*(Fs/2)/R, before resampling.
Accepted Answer
More Answers (0)
Categories
Find more on Digital Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!