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 -------------------------------- -------------------------------------------------------------------------------
The following example creates a new mfir object by loading the mfir object from disk.
mf = mfir('mf.mat') mf = mfir('mf.xml')
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 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)
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 |
ps = [pole(1) pole(200)]; zs = [zero(50)]; pzm = pzmodel(1, ps, zs); pl = plist('pzmodel', pzm, 'fs', 1000); mf = mfir(pl)
Construct an MFIR based on the magnitude of the input AO/fsdata object a
'method' |
the design method: |
'win' |
Window function for frequency-sampling method |
'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)
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', []))
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)