0
$\begingroup$

How can I obtain a Zero Phase Moving Average Filter? I read for example in Matlab that filtfilt give you zero phase doing forward and backward filter, I dont understand well how that work, I think taking the same number of values in the past and future can give me that, but it isnt causal right?

$\endgroup$
  • $\begingroup$ That's correct: taking the same number in the past and the future will give you a zero phase filter (provided the coefficient values are (anti)symmetric), but the filter will not be causal. Does it need to be? Most offline processing does not require causality, hence filtfilt. $\endgroup$ – Peter K. Nov 26 '15 at 1:48
  • $\begingroup$ Can I obtain a zero phase without taking future values? $\endgroup$ – Pulse9 Nov 26 '15 at 1:50
  • $\begingroup$ Only in some esoteric situations. $\endgroup$ – Peter K. Nov 26 '15 at 1:53
  • $\begingroup$ boy, @PeterK., i can't imagine a truly linear-phase and causal filter that is truly IIR. i can't see how you would get symmetry without the thing being FIR. and, semantically, i would call a Truncated IIR (TIIR) a method of implementing a class of FIR. and then you don't get linear phase unless you to the filtfilt thing with it, blockwise, sorta like Powell-Chau. $\endgroup$ – robert bristow-johnson Nov 26 '15 at 3:32
  • $\begingroup$ This answer explains how filtfilt works. $\endgroup$ – Matt L. Nov 26 '15 at 7:48
2
$\begingroup$

A zero phase moving average filter is an odd length FIR filter with coefficients

$$h[n]=\begin{cases}\frac{1}{N},&\quad -(N-1)/2\le n\le (N-1)/2\\0,&\quad\text{otherwise}\end{cases}$$

where $N$ is the (odd) filter length. Since $h[n]$ has non-zero values for $n<0$, it is not causal, and consequently, it can only be implemented by adding a delay, i.e. by making it causal.

Note that you can't simply use Matlab's filtfilt function with that filter because even though you would get zero phase (with a delay), the magnitude of the filter's transfer function gets squared, corresponding to a triangular impulse response (i.e., input samples further away from the current sample receive less weight).

This answer explains in more detail what filtfilt does.

See also this related question.

$\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.