1-D digital filter of
filter always operates along the first non-singleton dimension.
Thus, the filter operates along the first dimension for column vectors and nontrivial
matrices and along the second dimension for row vectors.
Filter High-Frequency Fixed-Point Sinusoid from Signal
Filter a high-frequency fixed-point sinusoid from a signal that contains both a low- and high-frequency fixed-point sinusoid.
w1 = 0.1*pi; w2 = 0.6*pi; n = 0:999; xd = sin(w1*n) + sin(w2*n); x = sfi(xd,12); b = ufi([0.1:0.1:1,1-0.1:-0.1:0.1]/4,10); gd = (length(b)-1)/2; y = filter(b,1,x);
Plot the results, accomodating for the group delay of the filter.
plot(n(1:end-gd),x(1:end-gd)) hold on plot(n(1:end-gd),y(gd+1:end),'r--') axis([0 50 -2 2]) legend('Unfiltered Signal','Filtered Signal') xlabel('Sample Index (n)') ylabel('Signal Value')
The resulting plot shows both the unfiltered and filtered signals.
b — Filter coefficients
Filter coefficients, specified as a fixed-point vector.
x — Input data
Input data, specified as a fixed-point vector.
zi — Initial conditions for filter delays
 (default) | fixed-point vector | fixed-point matrix | fixed-point multidimensional array
If you do not specify a value for
zi, or if you specify
, it defaults to a fixed-point array with a value of
0 and the appropriate
dim — Dimension along which to operate
positive integer scalar
Dimension along which to operate, specified as a positive integer scalar.
y — Filtered data
fixed-point vector | fixed-point matrix | fixed-point multidimensional array
Filtered data, returned as a fixed-point
fi vector, matrix, or
zf — Final conditions for filter delays
vector | matrix | multidimensional array
Final conditions for filter delays, returned as a fixed-point
vector, matrix, or multidimensional array.
filterfunction only supports FIR filters. In the general filter representation b/a, the denominator a of an FIR filter is the scalar 1, which is the second input of this function.
If you want to specify initial conditions but do not know what
numerictypeto use, first try filtering your data without initial conditions. You can do so by specifying
for the input
zi. After performing the filtering operation, you have the
zf(if requested). Because the
zimust match that of
zf, you now know the
numerictypeto use for the initial conditions.
Filter length (L)
The filter length is
length(b) or the number of filter coefficients
specified in the fixed-point vector
Filter order (N)
The filter order is the number of states (delays) of the filter and is equal to
Direct-Form Transposed FIR Filter
fimath Propagation Rules
filter function uses these rules regarding
If any of the inputs has an attached
fimath, then it is used for intermediate calculations.
If more than one input has an attached
fimath, then the
fimathsmust be equal.
yis always associated with the default
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Variable-sized inputs are only supported when the
SumModeproperty of the governing
fimathis set to
Introduced in R2010a