filt
filt(b, a, x, [si])
Apply filter described by vectors a
and b
to vector x
, with an optional initial filter state vector si
(defaults to zeros).
Examples
-
Filter a vector using coefficients
a
andb
:julia> a = [1, -0.5]; julia> b = [0.25, 0.5]; julia> x = [1, 2, 3, 4, 5]; julia> filt(b, a, x) 5-element Array{Float64,1}: 0.25 1.0 1.625 2.375 3.1875
This example applies the filter described by the coefficient vectors
a
andb
to the input vectorx
. - Apply filter with an initial state vector:
julia> a = [1, -0.5]; julia> b = [0.25, 0.5]; julia> x = [1, 2, 3, 4, 5]; julia> si = [0.5, 0.75]; julia> filt(b, a, x, si) 5-element Array{Float64,1}: 0.375 1.4375 1.96875 2.984375 3.9921875
In this example, an initial filter state vector
si
is provided, which affects the output of the filter.
Common mistake example:
julia> a = [1, -0.5];
julia> b = [0.25, 0.5];
julia> x = [1, 2, 3, 4, 5];
julia> filt(b, a, x, [0.1, 0.2, 0.3])
ERROR: DimensionMismatch("Cannot multiply two vectors")
In this example, the initial state vector si
has a different length than the coefficient vectors a
and b
. It's important to ensure that the dimensions of the coefficient vectors and the initial state vector match for the filter operation to be valid.
See Also
User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.