Mercurial > hg > ltpda
comparison m-toolbox/classes/@parfrac/fromResidualsPolesDirect.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: fromResidualsPolesDirect | |
4 % | |
5 % DESCRIPTION: Construct a partial fraction TF from residuals, poles, and | |
6 % direct terms. | |
7 % | |
8 % CALL: pf = fromResidualsPolesDirect(a, pl) | |
9 % | |
10 % PARAMETER: pl - plist | |
11 % | |
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
13 function pf = fromResidualsPolesDirect(pf, pli) | |
14 | |
15 VERSION = '$Id: fromResidualsPolesDirect.m,v 1.9 2011/08/15 12:32:10 hewitson Exp $'; | |
16 | |
17 | |
18 % get pzmodel info | |
19 ii = parfrac.getInfo('parfrac', 'From Residuals/Poles/Direct'); | |
20 | |
21 % Set the method version string in the minfo object | |
22 ii.setMversion([VERSION '-->' ii.mversion]); | |
23 | |
24 % Combine input plist with default values | |
25 pl = applyDefaults(ii.plists, pli); | |
26 | |
27 % Set fields | |
28 pf.res = find(pl, 'res'); | |
29 pf.dir = find(pl, 'dir'); | |
30 | |
31 % deal with poles | |
32 poles = find(pl, 'poles'); | |
33 if isnumeric(poles) | |
34 pf.poles = poles; | |
35 elseif isa(poles, 'pz') | |
36 pf.poles = []; | |
37 for ii = 1:length(poles) | |
38 tpl = poles(ii).ri; | |
39 if (poles(ii).q > 0.5) || (poles(ii).q < 0.5) | |
40 pf.poles = [pf.poles tpl(1) tpl(2)]; | |
41 else | |
42 pf.poles = [pf.poles tpl]; | |
43 end | |
44 end | |
45 elseif iscell(poles) | |
46 pf.poles = []; | |
47 for jj = 1:length(poles) | |
48 tpl = poles{jj}; | |
49 pf.poles = [pf.poles tpl]; | |
50 end | |
51 else | |
52 error('### Poles are in unknown format'); | |
53 end | |
54 | |
55 % Checking for high multiplicity poles | |
56 res = pf.res; | |
57 pls = pf.poles; | |
58 % mults contain poles multiplicity and indx is the corresponding position | |
59 [mults, indx] = mpoles( pls, 1e-15, 0 ); | |
60 % Sorting poles and residues in the mults order | |
61 pf.res = res(indx); | |
62 pf.poles = pls(indx); | |
63 pf.pmul = mults.'; % a vector with the corresponding poles multiplicity | |
64 | |
65 if numel(pf.poles) ~= numel(pf.res) | |
66 error('### The number of residual and poles must be equal.'); | |
67 end | |
68 | |
69 % Add history | |
70 pf.addHistory(ii, pl, [], []); | |
71 | |
72 % Set object properties from input plist | |
73 pf.setObjectProperties(pl); | |
74 | |
75 end |