Implementing FILTFILT using FILTER
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello fellow Matlab users,
I am trying to understand how FILTFILT.m works & am trying to implement it using FILTER.m. To my understanding:
1. It uses reflected signal extension at the edges (left and right side of original signal).
2. Length of each reflected extension is 3*(filter_order-1).
3. Signal is filtered in forward direction.
4. Then filtered signal from 3 is filtered in backward direction.
5. Finally, filtered output from 4 (after flipping the filtered signal) corresponding to original signal length is chosen as output.
I have implemented the above in 2 m-files. One is a function I wrote (my_filtfilt.m) and the other one (compare_matlab_filtfilt_my_filtfilt.m) calls this function and Matlab filtfilt.m for comparison.
While results are close for a noisy Matlab sample ECG signal (>> load noisysignals x), they are not EXACTLY identical (see attached image/plot)!
Also attached are my m-files.
How to make the 2 outputs to match perfectly?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149200/image.png)
Any help would be greatly appreciated :)
Thanks!
Saif
0 commentaires
Réponses (1)
Martin Schätz
le 17 Oct 2015
Hi, my first idea is that the signal is not padded with zeroes, but mirrored (as is used in 2D convolution). Because as i understand filtfilt, you are doing all as it should be.
0 commentaires
Voir également
Catégories
En savoir plus sur Digital Filtering dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!