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

From STX Wiki
Jump to navigationJump to search
(initial import)
 
No edit summary
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====fir1=====
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 &le; ''f1'' < ''f2'' &le; 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</var>, <var>x</var>{, <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: [[../iir1|iir1]]


A Finite Impulse Response (FIR) filter.
[[../#Functions|<function list>]]
 
=====Usage:=====
 
<code>fir1(<var>f1</var>, <var>f2</var>, <var>n</var>)</code>
 
=====Function:=====
 
Computes the filter coefficients for a FIR filter with cutoff frequencies <var>f1</var>, <var>f2</var> and the length <code>2*</code><var>n</var><code>+1</code>.
 
=====Result:=====
 
A vector with <code>2*</code><var>n</var><code>+1</code> filter coefficients.
 
=====Usage:=====
 
<code>fir1(<var>f1</var>, <var>f2</var>, <var>n</var>, <var>x</var>)</code>
 
=====Function:=====
 
Computes the filter coefficients for a FIR filter with cutoff frequencies <var>f1</var>, <var>f2</var> and the length <code>2*</code><var>n</var><code>+1</code> and applies the computed filter to the signal vector <var>x</var>.
 
=====Result:=====
 
The FIR filtered signal.
 
=====Return Type:=====
 
Same as <var>x</var>.

Latest revision as of 19:22, 21 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>

Navigation menu

Personal tools