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?
1 Answer
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.
filtfilt
. $\endgroup$filtfilt
thing with it, blockwise, sorta like Powell-Chau. $\endgroup$filtfilt
works. $\endgroup$