fir1

From STX Wiki
Jump to navigationJump to search

Create and/or apply a FIR filter.


Usage 1
fir1(f1, f2 , m)
f1, f2
the lower and upper cutoff frequency; both values must be specified as relative frequencies (f / sampling-rate); 0 <= f1 < f2 <= 0.5
m
the number of filter taps
Result
The function computes the FIR coefficients for the filter defined by the arguments and returns a vector c with 2m+1 elements. The result c can be used to apply the filter to a signal (see Usage 3).

Usage 2
fir1(f1, f2, m, x)
f1, f2, m
see Usage 1
x
a vector containing the source signal
Result
The function computes the filter coefficients for the FIR defined by the arguments and applies it to the signal x. The result has the same type as the input signal x and containes the filtered signal.

Usage 3
fir1(c, z, x{, s})
c
FIR filter coefficients (see Usage 1)
z
the filter state (delay); must be a vector with the same length as c
notes:
  • The vector should be initialized with zeros (e.g.: #z := eval fill($#c[!nrow],0,0))
  • The values of z are changed (z must be a reference to a table item
x
the signal sample (scalar) or the signal vector to be filtered
s
the downsampling factor; must be an integer in the range 0<s<ncol(x) (default=1)
note:
  • If s>1, only the filter output values y[0], y[s], y[2s], ... are stored in the result.
  • If s>1, nrow(x) should be a multiple of s.
Result
The filtered signal (sample or vector). The argument (reference) z is updated with the new filter state.

See also
iir1

<function list>



fir1

A Finite Impulse Response (FIR) filter.

Usage:

fir1(f1, f2, n)

Function:

Computes the filter coefficients for a FIR filter with cutoff frequencies f1, f2 and the length 2*n+1.

Result:

A vector with 2*n+1 filter coefficients.

Usage:

fir1(f1, f2, n, x)

Function:

Computes the filter coefficients for a FIR filter with cutoff frequencies f1, f2 and the length 2*n+1 and applies the computed filter to the signal vector x.

Result:

The FIR filtered signal.

Return Type:

Same as x.

Navigation menu

Personal tools