Frequency Domain Filter Implementation
Duality between the time domain and the frequency domain makes it possible to perform any operation in either domain. Usually one domain or the other is more convenient for a particular operation, but you can always accomplish a given operation in either domain.
To implement general IIR filtering in the frequency domain, multiply the discrete Fourier transform (DFT) of the input sequence with the quotient of the DFT of the filter:
n = length(x); y = ifft(fft(x).*fft(b,n)./fft(a,n));
This computes results that are identical to filter
, but with different startup transients
(edge effects). For long sequences, this computation is very inefficient
because of the large zero-padded FFT operations on the filter coefficients,
and because the FFT algorithm becomes less efficient as the number
of points n
increases.
For FIR filters, however, it is possible to break longer sequences into shorter, computationally efficient FFT lengths. The function
y = fftfilt(b,x)
uses the overlap add method to filter a long sequence with multiple
medium-length FFTs. Its output is equivalent to filter(b,1,x)
.