What is the difference between filter and conv in Matlab?

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.


conv(x,b) performs the complete convolution. The length of the result is length(x)+ length(b)-1. filter(b,[1],x) gives an output of the same length than x. It doesn’t flush the delay line of the filter.

Assume x is a row vector. Make x0 = [x zeros(1,length(b)-1)]; now filter(b,[1],x0) is the same as conv(x,b). This is because the additional 0’s are used to flush the delay line.

Which one is more reasonable? It depends of what you need!