What is the difference between filter and conv in Matlab?

nikos picture nikos · Dec 6, 2011 · Viewed 25k times · Source

I am trying to calculate the output of a LTI system. I came across two different Matlab functions that are supposed to be appropriate for the job: filter and conv. What is the difference between the two of them?

Answer

mtrw picture mtrw · Dec 6, 2011

filter can handle FIR and IIR systems, while conv takes two inputs and returns their convolution. So conv(h,x) and filter(h,1,x) would give the same result. The 1 in filter indicates that the recursive coefficients of the filter are just [1]. But if you have an IIR filter, you can't use conv. filter can also return the filter states, so that it can be used in subsequent calls without incurring filter transients.

See the conv and filter documentation for details.