Mercurial > hg > ltpda
comparison m-toolbox/classes/@parfrac/fromPzmodel.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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
2 % | |
3 % FUNCTION: fromPzmodel | |
4 % | |
5 % DESCRIPTION: Construct a parfrac from a pzmodel | |
6 % | |
7 % CALL: r = fromPzmodel(a, pl) | |
8 % | |
9 % PARAMETER: pl - plist | |
10 % | |
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
12 function r = fromPzmodel(r, pli) | |
13 | |
14 VERSION = '$Id: fromPzmodel.m,v 1.15 2011/08/15 12:31:51 hewitson Exp $'; | |
15 | |
16 | |
17 % get pzmodel info | |
18 ii = parfrac.getInfo('parfrac', 'From Pzmodel'); | |
19 | |
20 % Set the method version string in the minfo object | |
21 ii.setMversion([VERSION '-->' ii.mversion]); | |
22 | |
23 % Combine input plist with default values | |
24 pl = applyDefaults(ii.plists, pli); | |
25 | |
26 % Set fields | |
27 pzm = find(pl, 'pzmodel'); | |
28 | |
29 %--- Convert to parfrac | |
30 | |
31 ps = []; | |
32 zs = []; | |
33 if ~isempty(pzm.poles(:)) | |
34 ps = vertcat(pzm.poles(:).ri); | |
35 end | |
36 if ~isempty(pzm.zeros(:)) | |
37 zs = vertcat(pzm.zeros(:).ri); | |
38 end | |
39 | |
40 % get math gain out of the pzmodel | |
41 gs = utils.math.getk(zs,ps,pzm.gain); | |
42 [res, poles, dterms, pmul] = utils.math.cpf('INOPT', 'PZ', ... | |
43 'POLES', ps, ... | |
44 'ZEROS', zs, ... | |
45 'GAIN', gs, ... | |
46 'MODE', 'SYM'); | |
47 | |
48 r.res = res; | |
49 r.poles = poles; | |
50 r.pmul = pmul; | |
51 r.dir = dterms; | |
52 | |
53 % Set other properties | |
54 if isempty(pl.find('ounits')) | |
55 pl.pset('ounits', pzm.ounits); | |
56 end | |
57 | |
58 if isempty(pl.find('iunits')) | |
59 pl.pset('iunits', pzm.iunits); | |
60 end | |
61 | |
62 if isempty(pl.find('name')) | |
63 pl.pset('name', sprintf('parfrac(%s)', pzm.name)); | |
64 end | |
65 | |
66 if isempty(pl.find('description')) | |
67 pl.pset('description', pzm.description); | |
68 end | |
69 | |
70 % Add history | |
71 r.addHistory(ii, pl, [], pzm.hist); | |
72 | |
73 % Set object properties | |
74 r.setObjectProperties(pl); | |
75 | |
76 end |