Constructor examples of the MFIR class


Construct empty MFIR object
Construct a MFIR object by loading the object from a file
Construct a MFIR object from an Analysis Object
Construct a MFIR object from a parameter list (PLIST)
Construct a MFIR object from an existing model
Construct a MFIR object from a difference equation

Construct empty MFIR object

The following example creates an empty mfir object

mf = mfir()
-------- None / $Id: mfir.m,v 1.36 2008/03/24 23:51:38 mauro Exp ------------

created: 2008-03-30 16:07:54.311
version: $Id: mfir.m,v 1.36 2008/03/24 23:51:38 mauro Exp
   name: None
     fs: 0
  ntaps: 0
      a:
   gain: 0
histout:
Parameters:
----------- plist 01 -----------
n params: 0
--------------------------------

-------------------------------------------------------------------------------

Construct a MFIR object by loading the object from a file

The following example creates a new mfir object by loading the mfir object from disk.

mf = mfir('mf.mat')
mf = mfir('mf.xml')

Construct a MFIR object from an Analysis Object

FIR filter can be generated based on the magnitude of the input Analysis Object or fsdata object. In the following example a fsdata object is first generated and then passed to the mfir constructor to obtain the equivalent FIR filter.

fs = 1000;
f  = linspace(0, fs/2, 1000);
y  = randn(1000,1);
a1 = ao(fsdata(f,y,fs));

mf = mfir(a1);

Construct a MFIR object from a parameter list (PLIST)

Use the key word 'type'

Construct an MIIR of a standard type.

'type'

one of the types: 'highpass', 'lowpass', 'bandpass', 'bandreject' [default 'lowpass']

You can also specify optional parameters:

'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']

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)

Use the key word 'pzmodel'

The following example creates a mfir object from a pole/zero model.

'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]

ps = [pole(1) pole(200)];
zs = [zero(50)];
pzm = pzmodel(1, ps, zs);
pl = plist('pzmodel', pzm, 'fs', 1000);

mf = mfir(pl)

Use the key word 'ao'

Construct an MFIR based on the magnitude of the input AO/fsdata object a

'method'

the design method:
'frequency-sampling' - uses fir2()
'least-squares' - uses firls()
'Parks-McClellan' - uses firpm()
[default: 'frequency-sampling']

'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.

fs = 1000;
f  = linspace(0, fs/2, 1000);
y  = randn(1000,1);
a1 = ao(fsdata(f,y,fs));

pl = plist('ao', a1);

mf = mfir(pl)

Construct a MFIR object from an existing model

The mfir constructor also accepts as an input existing models 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 repository

f = mfir(plist('hostname', 'localhost', 'database', 'ltpda', 'ID', []))

Construct a MFIR object from a difference equation

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:

b  = [-0.8 10];
fs = 1;

f = mfir(b,fs)




©LTP Team