LTPDA Toolbox™ | contents | ![]() ![]() |
The following example creates a copy of an FIR filter object (blue command).
>> fir1 = mfir(plist('type', 'lowpass')); >> fir2 = mfir(fir2) ------ mfir/1 ------- gd: 32.5 version: $Id: mfir.m,v 1.84 2009/02/24 17:02:44 ingo Exp ntaps: 65 fs: 1 infile: a: [0.0007 0.0004 -6.9093e-19 -0.0006 -0.0012 -0.0014 -0.0011 1.4147e-18 ... histout: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... iunits: [] [1x1 unit] ounits: [] [1x1 unit] hist: mfir.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.
>> fir1 = mfir() ------ mfir/1 ------- gd: [] version: $Id: mfir.m,v 1.84 2009/02/24 17:02:44 ingo Exp ntaps: 0 fs: [] infile: a: [] histout: [] iunits: [] [1x1 unit] ounits: [] [1x1 unit] hist: mfir.hist [1x1 history] name: none --------------------- >> fir2 = fir1; >> fir2.setName('my new name') ------ mfir/1 ------- gd: [] version: $Id: mfir.m,v 1.84 2009/02/24 17:02:44 ingo Exp ntaps: 0 fs: [] infile: a: [] histout: [] iunits: [] [1x1 unit] ounits: [] [1x1 unit] hist: mfir.hist [1x1 history] name: my new name ---------------------
If we display fir1 again then we see that the property 'name' was changed although we only have changed fir2.
>> fir1
------ mfir/1 -------
gd: []
version: $Id: mfir.m,v 1.84 2009/02/24 17:02:44 ingo Exp
ntaps: 0
fs: []
infile:
a: []
histout: []
iunits: [] [1x1 unit]
ounits: [] [1x1 unit]
hist: mfir.hist [1x1 history]
name: my new name
---------------------
The following example creates a new mfir object by loading the mfir object from disk.
fir = mfir('fir.mat') fir = mfir('fir.xml')
or in a PLIST
pl = plist('filename', 'fir.xml'); fir = mfir(pl)
An FIR filter object can be generated based on the magnitude of the input AO/fsdata object. In the following example an AO/fsdata object is first generated and then passed to the mfir constructor to obtain the equivalent FIR filter.
a1 = ao(plist('fsfcn', '1./(50+f)', 'fs', 1000, 'f', linspace(0, 500, 1000))); fir = mfir(a1); iplot(a1, resp(fir));
or in a PLIST with the relevant parameters:
Key | Description |
---|---|
'method' |
the design method: |
'win' |
Window function for frequency-sampling method [default: 'Hanning'] |
'N' |
Filter order [default: 512] |
The following example creates a mfir object from an analysis object.
a1 = ao(plist('fsfcn', '1./(50+f)', 'fs', 1000, 'f', linspace(0, 500, 1000))); pl = plist('ao', a1); fir = mfir(pl)
The following example creates a new FIR 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) ------------------- >> fir = mfir(pzm) % Use the default sample rate fs=8 * frequency of the highest pole or zero in the model >> fir = mfir(pzm, plist('fs', 100)) ------ mfir/1 ------- gd: 257 version: $Id: mfir.m,v 1.84 2009/02/24 17:02:44 ingo Exp ntaps: 513 fs: 100 infile: a: [-0 -3.013e-10 -1.2486e-09 -2.8506e-09 -5.1166e-09 -7.8604e-09 -1.1133e-08 ... histout: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... iunits: [] [1x1 unit] ounits: [] [1x1 unit] hist: mfir.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) >> fir = mfir(pl)
Construct an FIR 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 = mfir(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 = mfir(pl)
The mfir constructor also accepts as an input existing filters stored in different formats:
LISO files
f = mfir('foo_fir.fil')
XML files
f = mfir('foo_fir.xml')
MAT files
f = mfir('foo_fir.mat')
From an LTPDA repository
The relevant parameters for retrieving a FIR 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 = mfir(plist('hostname', 'localhost', 'database', 'ltpda', 'ID', []))
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 FIR filter with sampling frequency 1 Hz and the following recursive equation:
a = [-0.8 10]; fs = 1; f = mfir(a,fs)
or in a PLIST
The relevant parameters are:
Key | Description |
---|---|
'a' |
vector of A coefficients. (see note ** below) [default: empty] |
'fs' |
sampling frequency of the filter [default: empty] |
'name' |
name of filter [default: 'None'] |
a = [-0.8 10]; fs = 1; pl = plist('a', a, 'fs', fs); fir = mfir(pl)
![]() |
Constructor examples of the SMODEL class | Constructor examples of the MIIR class | ![]() |
©LTP Team