-1
$\begingroup$

I am trying to extract features from a signal using filtfilt function in MATLAB. I implement the filtfilt function on my original signal using a high pass filter(second derivative) and use the peak of the second derivative to find my feature in the original signal. When I use filtfilt without a negative sign the signal is reversed and the features I am looking at is wrong but when I use
-filtfilt I can see that the signal is not reversed and the features i am looking at is right. How does -filtfilt work? what makes the signal reversed?

$\endgroup$
2
$\begingroup$

filtfilt fuction of Matlab / Octave does not require a negative sign. It performs forward and reverse filtering of a given signal $x[n]$ so as to obtain zero phase filtering.

Consider an LTI filter with real impulse response $h[n]$ whose frequency response is $H(\omega) = A(\omega) e^{j\phi(\omega) }$. Where $A(\omega) = |H(\omega)|$ and $\phi(\omega) = \angle{H(\omega)}$.

Then first apply this filter to your signal $x[n]$ to get the intermediate signal $w[n]$ :

$$ w[n] = h[n] \star x[n] \leftrightarrow W(\omega) = H(\omega)X(\omega) $$

Then filter the intermediate $w[n]$ by $h[-n]$ to get the final $y[n]$.

$$ y[n] = h[-n] \star w[n] \leftrightarrow Y(\omega) = H(-\omega)H(\omega)X(\omega) $$

Note that if $h[n]$ is real then $$A(-\omega) = A(\omega) ~~~\text{ and } ~~~\phi(-\omega) = -\phi(\omega)$$

Then the output $Y(\omega)$ will be

$$ \begin{align} Y(\omega) &= A(-\omega) e^{j\phi(-\omega)}A(\omega) e^{j\phi(\omega)}X(\omega)\\ &= A(\omega) e^{-j\phi(\omega)}A(\omega) e^{j\phi(\omega)}X(\omega) \\ &= A^2(\omega) X(\omega) \end{align} $$

That's; the frequency response of the effective filter is : $$\boxed{ Y(\omega) = |H(\omega)|^2 X(\omega) }$$ which is zero phase.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.