LTPDA Toolbox™ | contents | ![]() ![]() |
The following example creates a copy of an IIR filter object (blue command).
>> iir1 = miir(plist('type', 'lowpass')); >> iir2 = miir(iir2) ------ miir/1 ------- b: [1 -0.509525449494429] histin: 0 version: $Id: miir.m,v 1.98 2009/02/20 15:59:48 nicola Exp ntaps: 2 fs: 1 infile: a: [0.245237275252786 0.245237275252786] histout: 0 iunits: [] [1x1 unit] ounits: [] [1x1 unit] hist: miir.hist [1x1 history] name: lowpass ---------------------
REMARK: The following command copies only the handle of an object and doesn't create a copy of the object (as above). This means that everything that happens to the copy or original happens to the other object.
>> iir1 = miir() ------ miir/1 ------- b: [] histin: [] version: $Id: miir.m,v 1.98 2009/02/20 15:59:48 nicola Exp ntaps: 0 fs: [] infile: a: [] histout: [] iunits: [] [1x1 unit] ounits: [] [1x1 unit] hist: miir.hist [1x1 history] name: none --------------------- >> iir2 = iir1; >> iir2.setName('my new name') ------ miir/1 ------- b: [] histin: [] version: $Id: miir.m,v 1.98 2009/02/20 15:59:48 nicola Exp ntaps: 0 fs: [] infile: a: [] histout: [] iunits: [] [1x1 unit] ounits: [] [1x1 unit] hist: miir.hist [1x1 history] name: my new name ---------------------
If we display iir1 again then we see that the property 'name' was changed although we only have changed iir2.
>> iir1
------ miir/1 -------
b: []
histin: []
version: $Id: miir.m,v 1.98 2009/02/20 15:59:48 nicola Exp
ntaps: 0
fs: []
infile:
a: []
histout: []
iunits: [] [1x1 unit]
ounits: [] [1x1 unit]
hist: miir.hist [1x1 history]
name: my new name
---------------------
The following example creates a new miir object by loading the miir object from disk.
f = miir('f.mat') f = miir('f.xml')
or in a PLIST
pl = plist('filename', 'iir.xml'); iir = miir(pl)
An IIR filter object can be generated based on a parfrac object. The next example shows how you can convert a parfrac object into a iir filter object.
pf = parfrac([1 2+1i 2-1i], [6 1+3i 1-3i], 3); iir = miir(pf)
or in a PLIST with the relevant parameters:
Key | Description |
---|---|
'parfrac' |
a parfrac object to construct the filters from [default: empty parfrac] |
'fs' |
sample rate for the filter(s) [default: 8 * upper frequency of the parfrac object] |
The following example creates a IIR filter object from an parfrac object.
pf = parfrac([1 2+1i 2-1i], [6 1+3i 1-3i], 3); pl = plist('parfrac', pf, 'fs', 100);
The following example creates a new IIR filter object from a pole/zero model.
>> pzm = pzmodel(1, {1 2 3}, {4 5}, 'my pzmodel') ---- pzmodel 1 ---- name: my pzmodel gain: 1 delay: 0 iunits: [] ounits: [] pole 001: (f=1 Hz,Q=NaN) pole 002: (f=2 Hz,Q=NaN) pole 003: (f=3 Hz,Q=NaN) zero 001: (f=4 Hz,Q=NaN) zero 002: (f=5 Hz,Q=NaN) ------------------- >> iir = miir(pzm) % Use the default sample rate fs=8 * frequency of the highest pole or zero in the model >> iir = miir(pzm, plist('fs', 100)) ------ miir/1 ------- b: [1 -0.6485 -1.9619 1.3364 0.9644 -0.6854] histin: [0 0 0 0 0] version: $Id: miir.m,v 1.98 2009/02/20 15:59:48 nicola Exp ntaps: 6 fs: 100 infile: a: [0.0102 0.0152 -0.0097 -0.0186 0.0019 0.0057] histout: [0 0 0 0 0] iunits: [] [1x1 unit] ounits: [] [1x1 unit] hist: miir.hist [1x1 history] name: my pzmodel ---------------------
or in a PLIST with the relevant parameters:
Key | Description |
---|---|
'pzmodel' |
A pzmodel object to construct the filter from [default: empty pzmodel] |
'fs' |
Sample rate [default: 8 * frequency of the highest pole or zero in the model] |
>> pzm = pzmodel(1, {1 2 3}, {4 5}, 'my pzmodel') >> pl = plist('pzmodel', pzm, 'fs', 100) >> iir = miir(pl)
Construct an IIR filter object from a standard type: 'lowpass', 'highpass', 'bandpass' or 'bandreject'
The relevant parameters are:
Key | Description |
---|---|
'type' |
one of the types: 'highpass', 'lowpass', 'bandpass', 'bandreject' |
You can also specify optional parameters:
Key | Description |
---|---|
'gain' |
The gain of the filter [default: 1] |
'fc' |
The roll-off frequency [default: 0.1 Hz] |
'fs' |
The sampling frequency to design for [default: 1 Hz] |
'order' |
The filter order [default: 64] |
'win' |
Specify window function used in filter design [default: 'Hamming'] |
'iunits' |
the input unit of the filter |
'ounits' |
the output unit of the filter |
The following example creates an order 64 highpass filter with high frequency gain 2. Filter is designed for 1 Hz sampled data and has a cut-off frequency of 0.2 Hz.
pl = plist('type', 'highpass', ... 'order', 64, ... 'gain', 2.0, ... 'fs', 1, ... 'fc', 0.2); f = miir(pl)
Furthermore it is possible to specify a spectral window.
win = specwin('Kaiser', 11, 150); pl = plist('type', 'lowpass', ... 'Win', win, ... 'fs', 100, ... 'fc', 20, ... 'order', 10); f = miir(pl)
The miir constructor also accepts as an input existing models in different formats:
LISO files
f = miir('foo_iir.fil')
XML files
f = miir('foo_iir.xml')
MAT files
f = miir('foo_iir.mat')
From repository
The relevant parameters for retrieving a IIR filter from a LTPDA repository are:
Key | Description |
---|---|
'hostname' |
the repository hostname. [default: 'localhost'] |
'database' |
The database name [default: 'ltpda'] |
'id' |
A vector of object IDs. [default: []] |
'cid' |
Retrieve all rational objects from a particular collection |
'binary' |
Set to true to retrieve from stored binary representation (not always available). [default: true] |
f = miir(plist('hostname', 'localhost', 'database', 'ltpda', 'ID', []))
Alternatively, the filter can be defined in terms of two vectors specifying the coefficients of the filter and the sampling frequency. The following example creates a IIR filter with sampling frequency 1 Hz and the following recursive equation:
a = [0.5 -0.01]; b = [1 0.1] fs = 1; f = miir(a,b,fs)
or in a PLIST
The relevant parameters are:
Key | Description |
---|---|
'a' |
vector of A coefficients (see note ** below) [default: empty] |
'b' |
vector of B coefficients (see note ** below) [default: empty] |
'fs' |
sampling frequency of the filter [default: empty] |
'name' |
name of filter [default: 'None'] |
a = [0.5 -0.01]; b = [1 0.1] fs = 1; name = 'my IIR'; pl = plist('a', a, 'fs', fs, 'name', name); iir = miir(pl)
![]() |
Constructor examples of the MFIR class | Constructor examples of the PZMODEL class | ![]() |
©LTP Team