Programmer Guide/Command Reference/EVAL/fir1: Difference between revisions
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
---- | ---- | ||
;Usage 2: <code>fir1(<var>f1</var>, <var>f2</var>, <var>m</var>, <var>x</var>)</code> | ;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>f1, f2, m</var>: see '''Usage 1''' | ||
:;<var>x</var>: a vector containing the source signal | :;<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. | ;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. | ||
Line 17: | Line 17: | ||
::notes: | ::notes: | ||
::*The vector should be initialized with zeros (e.g.: <code>#z := eval fill($#c[!nrow],0,0)</code>) | ::*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]] | ::*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>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) | :;<var>s</var>: the downsampling factor; must be an integer in the range <code>0<''s''<ncol(''x'')</code> (default=1) | ||
Line 29: | Line 29: | ||
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]] | [[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]] | ||
Revision as of 13:30, 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)
- The vector should be initialized with zeros (e.g.:
- 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