Mercurial > hg > ltpda
comparison m-toolbox/classes/@ssm/ssmFromParfrac.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: ssmFromParfrac | |
4 % | |
5 % DESCRIPTION: Construct a statespace model from a ssmFromParfrac | |
6 % | |
7 % CALL: see ssm, this function is private | |
8 % | |
9 % TODO: check must be made there is no pole zero cancelation | |
10 % | |
11 % VERSION : '$Id: ssmFromParfrac.m,v 1.10 2010/08/27 13:09:56 adrien Exp $'; | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 | |
15 function varargout = ssmFromParfrac(varargin) | |
16 | |
17 VERSION = '$Id: ssmFromParfrac.m,v 1.10 2010/08/27 13:09:56 adrien Exp $'; | |
18 utils.helper.msg(utils.const.msg.MNAME, ['running ', mfilename]); | |
19 % get info | |
20 ii = ssm.getInfo('ssm', 'From Description'); | |
21 % Set the method version string in the minfo object | |
22 ii.setMversion([VERSION '-->' ii.mversion]); | |
23 | |
24 if nargin ~=2 | |
25 error('ssmFromRational need 2 inputs : (obj, plist) ') | |
26 elseif isa(varargin{1}, 'parfrac') && isa(varargin{2}, 'plist') | |
27 pl = combine(varargin{2}, ii.plists); | |
28 parfracsin = varargin{1}; | |
29 else | |
30 error('### Please input (<object>,<plist>)'); | |
31 end | |
32 | |
33 ssmout = ssm.initObjectWithSize(size(parfracsin,1),size(parfracsin,2)); | |
34 for i =1:numel(parfracsin) | |
35 | |
36 res = parfracsin(i).res; | |
37 poles = parfracsin(i).poles; | |
38 dterm = parfracsin(i).dir; | |
39 pmul = parfracsin(i).pmul; | |
40 | |
41 % check poles multiplicity | |
42 for jj=1:length(pmul) | |
43 if pmul(jj)~=1; | |
44 error('!!! Poles multiplicity higher than 1 is not supported') | |
45 end | |
46 end | |
47 | |
48 % willing to work with columns | |
49 if size(res,2)>1 | |
50 res = res.'; | |
51 end | |
52 if size(poles,2)>1 | |
53 poles = poles.'; | |
54 end | |
55 | |
56 Nss = numel(poles); | |
57 | |
58 % convert to state space matrices | |
59 [A,B,C,D] = utils.math.pf2ss(res,poles,dterm); | |
60 | |
61 | |
62 | |
63 ssmout(i).dmats = {D}; | |
64 ssmout(i).amats = {A}; | |
65 ssmout(i).bmats = {B}; | |
66 ssmout(i).cmats = {C}; | |
67 | |
68 ssmout(i).name = parfracsin(i).name; | |
69 ssmout(i).timestep = 0; | |
70 ssmout(i).addHistory(ii, pl, {''}, parfracsin(i).hist); | |
71 | |
72 inputstr = 'input'; | |
73 outputstr = 'output'; | |
74 ssstr = 'state'; | |
75 | |
76 ssmout(i).inputs = ssmblock.makeBlocksWithData({inputstr}, [], {{inputstr}}, {parfracsin(i).iunits}, []); | |
77 ssmout(i).outputs = ssmblock.makeBlocksWithData({outputstr}, [], {{outputstr}}, {parfracsin(i).ounits}, []); | |
78 ssmout(i).states = ssmblock.makeBlocksWithSize(Nss, ssstr); | |
79 | |
80 if ~strcmp(pl.find('name'),'none') | |
81 ssmout(i).name = pl.find('name'); | |
82 end | |
83 if ~strcmp(pl.find('description'),'') | |
84 ssmout(i).description = pl.find('description'); | |
85 end | |
86 end | |
87 | |
88 varargout = {ssmout}; | |
89 end | |
90 | |
91 |