Skip to content

filter

builtin · libnexusinterp/corefcn/filter-proprietary.cc

: y = filter (b, a, x)
: y = filter (b, a, x, si)
: [y, sf] = filter (…)

Apply the one-dimensional rational digital filter with numerator coefficients b and denominator coefficients a to the signal x and return the filtered result y.

The output satisfies the difference equation

a(1)*y(n) = b(1)*x(n)   + b(2)*x(n-1) + ... + b(nb)*x(n-nb+1)
                     - a(2)*y(n-1) - ... - a(na)*y(n-na+1)

where nb = length (b) and na = length (a). The coefficients are first normalized by a(1), which must be nonzero; supplying a zero (or empty) leading denominator coefficient is an error. y has the same number of elements as x, and the orientation of x is preserved so that a column input yields a column output.

The optional argument si gives the initial values of the filter’s delay states. It must contain max (length (b), length (a)) - 1 elements; when omitted the filter starts from rest. Requesting the second output sf returns the delay states remaining after the final sample, which can be fed back in as si to continue filtering a later block of data.

If any of b, a, x, or si is complex, the computation and the returned values are complex.