filtfilt vs. filter vs. self-implemented zero-phase filter
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi experts,
I am trying to use a bandpass filter to filter a signal in sig.mat
I used a 8th order bandpass butterworth filter, and implemented three methods: 1. filter 2. filtfilt 3. self-implemented zero-phase filter
However the results are all different. and the waveform amplitude of filtfilt is very different from method 1 and 3.
It's understandable that 1 and 3 has a phase shift in between, but it's very confusing because the filtfilt build-in has calculated some intial condition zi which makes the results from method 2 has a similar shape with 1 and 3 but has very small amplitude.
Here is my code and sig.mat file:
load('sig.mat');
fs = 30.0006; bp = [1.0517,1.2517];
[b,a] = butter(4, 2*bp/fs, 'bandpass');
% implement zero-phase by hand
zf = fliplr(filter(b,a,fliplr(filter(b,a,sig))));
figure, t= 1:300;
plot(t, sig, t, filter(b,a,sig), t, filtfilt(b,a,sig), t, zf);...
legend('sig','filter','filtfilt', 'self-implemented');
0 commentaires
Réponses (1)
Mathieu NOE
le 8 Oct 2020
hello
I found that your are using a narrow bandwith, high order filter, so that generates a looong impulse response.
with your settings the filter's response is even longer than your signal. And the signal itself is not very stationnary either.
So we have only transient's at the output at the filter and it get's even more bumpy by doing it twice with filtfilt.
I am not sure what kind of info you want to filter out and if the focus is on extracting a narrow bandwith extract and / or not respect the amplitude enveloppe of the input signal.
IMHO, it is necessary to analyse the signal time / frequency content (hence specgram demo) and adjust (sometimes with compromise) your bandpass filter's parameters depending of what info is most important in your filering.
Attached a few files / infos that could help you
0 commentaires
Voir également
Catégories
En savoir plus sur Digital Filtering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!