2
$\begingroup$

How is the filter() implemented in MATLAB? How is it so fast?
What's the fastest implementation of a FIR filter?

$\endgroup$
4
$\begingroup$

Actually it seems MATLAB implementation of the filter() function is pretty straight forward and not fast.

For a fast implementation, have a look at FilterM by Jan Simon.

Update

In the latest releases of MATLAB (From R2016b and above) the performance of the filter() function has improved.
The metdhos to accelerate those operations are usually based on:

  1. Utilizing SIMD Operations (SSE / AVX in x86).
  2. Multi Threading.
  3. Loop Unrolling.
| improve this answer | |
$\endgroup$
  • $\begingroup$ MATLAB uses a time domain Direct Form II Transposed Canonical structure to realize its filter() or conv() functions. It's not specifically designed to be fast. An FFT based implementation would be faster or fastest when data lengths are suitable... $\endgroup$ – Fat32 Nov 18 '19 at 13:32
  • $\begingroup$ Actually fft() based will be faster only in the cases dimensions are really perfect for it which doesn't happen often in my experience. Filtration both with fft() or directly on data are usually memory bounded and the fft() approach stresses memory more. $\endgroup$ – Royi Nov 18 '19 at 14:32
  • $\begingroup$ By the way, MATLAB's conv() is much faster than filter() in the cases of FIR filters. $\endgroup$ – Royi Nov 18 '19 at 14:33
  • $\begingroup$ I don't know your MATLAB version but in my(old) version its help says The conv function is an M-file that uses the filter primitive.... So I don't how how it could be faster ? May be newer versions use other approaches ? $\endgroup$ – Fat32 Nov 18 '19 at 17:54
  • $\begingroup$ And about fft() version, yes the length should be suitable for fastest performance, otherwise you will not get the benefit... $\endgroup$ – Fat32 Nov 18 '19 at 17:55

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.