Mercurial > hg > ltpda
comparison m-toolbox/classes/@miir/fromParfrac.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % Construct an miir from a parfrac | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % FUNCTION: fromParfrac | |
5 % | |
6 % DESCRIPTION: Construct an miir from a parfrac | |
7 % | |
8 % CALL: f = fromParfrac(f, pli) | |
9 % | |
10 % PARAMETER: type: String with filter type description | |
11 % pli: Parameter list object | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 function f = fromParfrac(f, pli) | |
15 | |
16 VERSION = '$Id: fromParfrac.m,v 1.12 2011/08/15 11:22:43 hewitson Exp $'; | |
17 ii = miir.getInfo('miir', 'From Parfrac'); | |
18 % Set the method version string in the minfo object | |
19 ii.setMversion([VERSION '-->' ii.mversion]); | |
20 | |
21 % Add default values | |
22 pl = applyDefaults(ii.plists, pli); | |
23 | |
24 % Get parameters | |
25 pf = find(pl, 'parfrac'); | |
26 fs = find(pl, 'fs'); | |
27 | |
28 if isempty(fs) | |
29 % get max freq in pzmodel | |
30 fs = 8*getupperFreq(pf); | |
31 warning([sprintf('!!! no sample rate specified. Designing for fs=%2.2f Hz.', fs)... | |
32 sprintf('\nThe filter will be redesigned later when used.')]); | |
33 end | |
34 % make MIIR filter | |
35 pfstruct = utils.math.lp2z('INOPT', 'PF', 'RES', pf.res, 'POLES', pf.poles, ... | |
36 'DTERMS', pf.dir, 'MODE', 'DBL', 'FS', fs); | |
37 | |
38 for jj=1:numel(pfstruct) | |
39 pl = copy(pl,1); | |
40 | |
41 f(jj).a = pfstruct(jj).num; | |
42 f(jj).b = pfstruct(jj).den; | |
43 f(jj).fs = fs; | |
44 | |
45 if isempty(pl.find('name')) | |
46 pl.pset('name', sprintf('iir(%s_%d)', pf.name, jj)); | |
47 end | |
48 if isempty(pl.find('description')) | |
49 pl.pset('description', pf.description); | |
50 end | |
51 if isempty(pl.find('iunits')) | |
52 pl.pset('iunits', pf.iunits); | |
53 end | |
54 if isempty(pl.find('ounits')) | |
55 pl.pset('ounits', pf.ounits); | |
56 end | |
57 | |
58 % Add history | |
59 f(jj).addHistory(ii, pl, [], pf.hist); | |
60 end | |
61 | |
62 % Set object properties | |
63 f.setObjectProperties(pl); | |
64 | |
65 end % End fromParfrac |