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

From STX Wiki
Jump to navigationJump to search
(initial import)
 
No edit summary
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====iir1=====
{{EVALFunctionTemplate}}
Create and/or apply an IIR filter.
----
;Usage 1: <code>iir1(<var>f1</var>, <var>f2</var>  {, <var>m</var>, <var>rp</var>, <var>rs</var>, <var>inv</var>, <var>type</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 filter order (default=5)
;<var>rp</var>: the desired passband ripple in dB; 0 < ''rp'' (default=0.5)
;<var>rs</var>: the desired stopband damping level in dB; 0 < ''rs'' (default=40)
;<var>inv</var>: invert filter response (0=no, 1=yes); if this value is set to 1, the filter frequency response is inverted and f1/f2 are the boundaries of the stopband
<var>type</var>: the type of the filter
::{|class="keinrahmen"
|''type''=1 ||... Butterworth filter
|''type''=2 ||... Chebyshev filter
|''type''=3 ||... elliptic filter (this is the default)
|}
;Result 1: The function computes the filter coefficients for the IIR defined by the arguments and returns a matrix ''c'' with 2 columns. The first column (''c''[*,0]) contains the denominator coefficients (poles) and the second (''c''[*,1]) the nominator coefficients (zeros). The matrix ''c'' can be used to apply the filter to a signal (see '''Usage 3''').
----
;Usage 2: <code>iir1(<var>f1</var>, <var>f2</var>, <var>m</var>, <var>rp</var>, <var>rs</var>, <var>inv</var>, <var>type</var>, <var>x</var>)</code>
:;<var>f1, f2, m, rp, rs, inv, type</var>: see '''Usage 1'''
:;<var>x</var>: a vector containing the source signal
;Result 2: The function computes the filter coefficients for the IIR 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>iir1(<var>c</var>, <var>z</var>, <var>x</var> {, <var>s</var>})</code>
:;<var>c</var>: IIR filter coefficients (see '''Usage 1''')
:;<var>z</var>: the filter state (delay); must be a matrix with the same dimensions as ''c''
::notes:
::*The matrix should be initialized with zeros (e.g.: <code>#z := eval init($#c[!nrow],$#c[!ncol],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 3: The filtered signal (sample or vector). The argument (reference) ''z'' is updated with the new filter state.
----
;See also: [[../fir1|fir1]]


An Infinite Impulse Response (IIR) filter.
[[../#Functions|<function list>]]
 
=====Usage:=====
 
<code>iir1(<var>f1</var>, <var>f2</var>, <var>m</var>, <var>rp</var>, <var>rs</var>, <var>inv</var>, <var>type</var>)</code>
 
=====Function:=====
 
Computes the filter coefficients for an IIR filter with cutoff frequencies <var>f1</var> and <var>f2</var> and the order <var>m</var>.
 
=====Parameters:=====
 
;<var>f1</var>
 
:The rel. lower cutoff frequency.
 
;<var>f2</var>
 
:The rel. upper cutoff frequency (<code>0 <=</code> <var>f1</var> <code><</code> <var>f2</var> <code><= 0.5</code>).
 
;<var>m</var>
 
:The filter order (<var>m</var> <code>>= 2</code>). The default is <code>3</code>.
 
;<var>rp</var>
 
:The passband riple in dB (<var>rp</var> <code>> 0</code>). The default is <code>0.5</code>.
 
;<var>rs</var>
 
:The stopband damping in dB (<var>rs</var> <code>> 0</code>). The default is <code>40</code>.
 
;<var>inv</var>
 
:The invert frequency response (<code>0</code>|<code>1</code>). The default is <code>0</code>.
 
;<var>type</var>
 
:The type of filter to use. The following values are supported:
 
:<code>1</code> A Butterworth filter
 
:<code>2</code> A Chebyshev filter
 
:<code>3</code> An elliptic filter (This is the default).
 
=====Result:=====
 
A matrix <code>c</code> with 2 columns:
 
(<code>c[*,0] = poles</code>, <code>c[*,1] = zeros</code>)
 
=====Usage:=====
 
<code>iir1(<var>f1</var>, <var>f2</var>, <var>m</var>, <var>rp</var>, <var>rs</var>, <var>inv</var>, <var>type</var>, <var>x</var>)</code>
 
=====Function:=====
 
Computes the filter coefficients for an IIR filter with cutoff frequencies <var>f1</var> and <var>f2</var> and the order <var>m</var> and apply it to the signal <var>x</var>.
 
=====Parameters:=====
 
;<var>x</var>
 
:A signal vector.
 
For all other parameters see <code>irr1</code> above.
 
=====Result:=====
 
A filtered signal of the same type as <var>x</var>.

Latest revision as of 15:28, 2 March 2015

Create and/or apply an IIR filter.


Usage 1
iir1(f1, f2 {, m, rp, rs, inv, type})
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 filter order (default=5)
rp
the desired passband ripple in dB; 0 < rp (default=0.5)
rs
the desired stopband damping level in dB; 0 < rs (default=40)
inv
invert filter response (0=no, 1=yes); if this value is set to 1, the filter frequency response is inverted and f1/f2 are the boundaries of the stopband

type: the type of the filter

type=1 ... Butterworth filter type=2 ... Chebyshev filter type=3 ... elliptic filter (this is the default)
Result 1
The function computes the filter coefficients for the IIR defined by the arguments and returns a matrix c with 2 columns. The first column (c[*,0]) contains the denominator coefficients (poles) and the second (c[*,1]) the nominator coefficients (zeros). The matrix c can be used to apply the filter to a signal (see Usage 3).

Usage 2
iir1(f1, f2, m, rp, rs, inv, type, x)
f1, f2, m, rp, rs, inv, type
see Usage 1
x
a vector containing the source signal
Result 2
The function computes the filter coefficients for the IIR 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
iir1(c, z, x {, s})
c
IIR filter coefficients (see Usage 1)
z
the filter state (delay); must be a matrix with the same dimensions as c
notes:
  • The matrix should be initialized with zeros (e.g.: #z := eval init($#c[!nrow],$#c[!ncol],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 3
The filtered signal (sample or vector). The argument (reference) z is updated with the new filter state.

See also
fir1

<function list>

Navigation menu

Personal tools