Mercurial > hg > ltpda
comparison m-toolbox/classes/@parfrac/fromRational.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: fromRational | |
4 % | |
5 % DESCRIPTION: Construct a parfrac from a rational TF | |
6 % | |
7 % CALL: pf = fromRational(a, pl) | |
8 % | |
9 % PARAMETER: pl - plist | |
10 % | |
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
12 function pf = fromRational(pf, pli) | |
13 | |
14 VERSION = '$Id: fromRational.m,v 1.12 2011/08/15 12:31:59 hewitson Exp $'; | |
15 | |
16 | |
17 % get pzmodel info | |
18 ii = parfrac.getInfo('parfrac', 'From Rational'); | |
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 rat = find(pl, 'rational'); | |
28 | |
29 % if the denominator is not a polynomial but a single number, then the | |
30 % model is not really a rational model. It is practically a polynomial | |
31 % model and cannot be converted in partial fractions. Output PF model | |
32 % will be a zero residues and poles. Dterms will contain the numerator | |
33 % polynomial | |
34 if numel(rat.den)==1 | |
35 pf.res = 0; | |
36 pf.poles = 0; | |
37 pf.dir = (rat.num)./(rat.den); | |
38 pf.pmul = 0; | |
39 else % convert a true rational model in partial fractions | |
40 [res, poles, dterms, pmul] = utils.math.cpf('INOPT', 'RAT', ... | |
41 'NUM', rat.num, ... | |
42 'DEN', rat.den, 'MODE', 'SYM'); | |
43 | |
44 pf.res = res; | |
45 pf.poles = poles; | |
46 pf.dir = dterms; | |
47 pf.pmul = pmul; | |
48 end | |
49 | |
50 % Set properties from rational object | |
51 if isempty(pl.find('ounits')) | |
52 pl.pset('ounits', rat.ounits); | |
53 end | |
54 | |
55 if isempty(pl.find('iunits')) | |
56 pl.pset('iunits', rat.iunits); | |
57 end | |
58 | |
59 if isempty(pl.find('name')) | |
60 pl.pset('name', sprintf('parfrac(%s)', rat.name)); | |
61 end | |
62 | |
63 if isempty(pl.find('description')) | |
64 pl.pset('description', rat.description); | |
65 end | |
66 | |
67 % Add history | |
68 pf.addHistory(ii, pl, [], rat.hist); | |
69 | |
70 % Set object properties | |
71 pf.setObjectProperties(pl); | |
72 | |
73 end |