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?
Convolution filters generate output images in which the brightness value at a particular pixel depends on the weighted sum (i.e. linear combination) of the brightness of the neighboring pixels. Mathematical morphology filters on the other hand perform nonlinear processing on images.
c = conv( a,b ) returns the convolution of input vectors a and b , at least one of which must be a fi object. example. c = conv( a,b , shape ) returns a subsection of the convolution, as specified by shape .
Filters are data processing techniques that can smooth out high-frequency fluctuations in data or remove periodic trends of a specific frequency from data. In MATLAB®, the filter function filters a vector of data x according to the following difference equation, which describes a tapped delay-line filter.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With