Programmer Guide/Command Reference/EVAL/fir1: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
Create and/or apply a FIR filter.
----
;Usage 1: <code>fir1(<var>f1</var>, <var>f2</var>  , <var>m</var>)</code>
:;<var>f1, f2</var>: the lower and upper cutoff frequency; both values must be specified as ''relative frequencies'' (f / sampling-rate); 0 <= ''f1'' < ''f2'' <= 0.5
;<var>m</var>: 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 2''m''+1 elements. The result ''c'' can be used to apply the filter to a signal (see '''Usage 3''').
----
;Usage 2: <code>fir1(<var>f1</var>, <var>f2</var>, <var>m</var>, <var>x</var>)</code>
:;<var>f1, f2, m</var>: see Usage 1
:;<var>x</var>: 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: <code>fir1(<var>c</var>, <var>z</sub>, <var>x</sub>{, <var>s</var>})</code>
:;<var>c</var>: FIR filter coefficients (see '''Usage 1''')
:;<var>z</var>: the filter state (delay); must be a vector with the same length as ''c''
::notes:
::*The vector should be initialized with zeros (e.g.: <code>#z := eval fill($#c[!nrow],0,0)</code>)
::*The values of ''z'' are changed (''z'' must be a ''reference'' to a [[Programmer_Guide/Shell_Items/Table|table item]]
:;<var>x</var>: the signal sample (scalar) or the signal vector to be filtered
:;<var>s</var>: the downsampling factor; must be an integer in the range <code>0<''s''<ncol(''x'')</code> (default=1)
::note:
::*If ''s''>1, only the filter output values y[0], y[''s''], y[2''s''], ... are stored in the result.
::*If ''s''>1, <code>nrow(''x'')</code> 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: [[Programmer_Guide/Command_Reference/EVAL/iir1|iir1]]
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====fir1=====
=====fir1=====

Revision as of 14:25, 11 April 2011

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