# Is it possible to design noncausal filters in Matlab?

I'm trying to design a lowpass IIR filter with 5Hz cutoff frequency (sample frequency is 200Hz). i know how to create it with fdatool, or with functions such as 'butter' or 'ellip'. However, i think that all the filters created are causal. Is it possible to create also noncausal filters? Thanks in advance

• What is your purpose? Any causal filter can be made non-causal by composing it with a negative delay, or by reversing the impulse response in time. But do you mean something less trivial? For instance, do you want to minimize delay spread? Zero phase? Etc. – Michael Grant Dec 17 '14 at 13:23
• when using MATLAB to design a linear-phase FIR filter, i always offset the impulse response (using fftshift()) to be symmetrical about 0 so that it's a zero-phase FIR. not sure how a non-causal IIR filter would work. i don't think it would be stable as $t \rightarrow \infty$. – robert bristow-johnson Dec 17 '14 at 16:37
• Of course, all physically realizable filters are necessarily causal. I hope that the OP will clarify what his true intentions are. – Michael Grant Dec 17 '14 at 18:04
• I just wanted to know if it was possible to design such filters in Matlab (for general purposes). What i have to implement is an online filter ( so, i know, in principle it has to be a causal filter). However, i can store some samples before computing the output value referred to a previous time (i can look "a bit in the future"). However as Michael said (if i have correctly understood you) i can shift backward in time later the computed output (and it seems quite simple). Thanks Taking the oppurtunity..do you know how to design filters with minimum group delay? – lorenzo0820 Dec 17 '14 at 20:08

The short answer is: yes, of course it's possible to design non-causal filters. Consider a simple first order IIR filter:

$$y[n]=ay[n-1]+bx[n]\tag{1}$$

If implemented in the way as indicated in Eq. (1), this filter is causal. It is also stable if $|a|<1$. Now rewrite (1) as

$$y[n-1]=\frac{1}{a}y[n]-\frac{b}{a}x[n]\tag{2}$$

Implemented in this way, you compute $y[n-1]$ from the future samples $y[n]$ and $x[n]$, so the system is anti-causal. Note that it is stable if $|a|>1$. Similar considerations apply to higher-order filters.

One way of realizing non-causal IIR filters is implemented in Matlab's filtfilt function. How this works is described in this answer.

Non-causal FIR filters can always be implemented by appropriate buffering of the input signal and delaying the output signal.