filterFilter for vectors
We consider a filter having the system function:
where filter is implemented based on the transposed direct form II structure:

For
y = filter(b, a, x, wi)[y, wf] = filter(b, a, x, wi)a and b are vectors of real numbers, containing filter coefficients a(1) and b(1) correspond to a and b have different lengths, the shorter vector will be packed with trailing zeros to match the length of the longer vector. As a result, max(length(a), length(b)) - 1.a(1) is not 1, each element of a and b are divided by a(1) before filtering. Hence, a(1) must be non-zero.x contains data to be filtered, and y contains the filtered data. The output y has the same size as x.wi contains values at the outputs of the delay blocks when the filtering begins.wi is a vector, it should have length x is multi-dimensional, the same vector wi is applied repeatedly to different dimensions of x.wi is multi-demensional, its size should be [N sz[1:(dim - 1) (dim + 1):ndims(x)]], where N is equal to max(length(a), length(b)) - 1, sz = size(x) and dim is the first nonsingleton dimension of x. wi is empty, all x is a vector, the filter is applied along the longer dimension. Otherwise, it is applied to vectors along the first nonsingleton dimension.wf contains values at the outputs of the delay blocks when the filtering ends. It has the size [N sz[1:(dim - 1) (dim + 1):ndims(x)]], where sz=size(x).y = filter(b, a, x)[y, wf] = filter(b, a, x)y = filter(b, a, x, wi) and [y, wf] = filter(b, a, x, wi) with wi being an array of zeros.y = filter(b, a, x, wi, dim)[y, wf]= filter(b, a, x, wi, dim)y = filter(b, a, x, wi) and [y, wf] = filter(b, a, x, wi) except that the filter is applied to vectors along the dim-th dimension.wi is a vector, it should have length max(length(a), length(b)) - 1. If x is multi-dimensional, the same vector wi is applied repeatedly to different dimensions of x.wi is multi-demensional, its size should be [N sz[1:(dim - 1) (dim + 1):ndims(x)]], where N is equal to max(length(a), length(b)) - 1 and sz = size(x). wi is empty, all dim should be a real positive integer scalar.