Mercurial > hg > ltpda
comparison m-toolbox/classes/@ssm/ssmFromPzmodel.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: ssmFromPzmodel | |
4 % | |
5 % DESCRIPTION: Construct a statespace model from a pzmodel | |
6 % | |
7 % CALL: see ssm, this function is private | |
8 % | |
9 % TODO : Modify using ss2zp/zp2ss | |
10 % | |
11 % VERSION : '$Id: ssmFromPzmodel.m,v 1.26 2011/04/08 08:56:23 hewitson Exp $'; | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 | |
15 function ssmout = ssmFromPzmodel(varargin) | |
16 | |
17 VERSION = '$Id: ssmFromPzmodel.m,v 1.26 2011/04/08 08:56:23 hewitson Exp $'; | |
18 utils.helper.msg(utils.const.msg.MNAME, ['running ', mfilename]); | |
19 % get info | |
20 ii = ssm.getInfo('ssm', 'from pzmodel'); | |
21 % Set the method version string in the minfo object | |
22 ii.setMversion([VERSION '-->' ii.mversion]); | |
23 | |
24 if nargin ~=2 | |
25 error('ssmFromPzmodel need 2 inputs : (obj, plist) ') | |
26 elseif isa(varargin{1}, 'pzmodel') && isa(varargin{2}, 'plist') | |
27 pl = combine(varargin{2}, ii.plists); | |
28 pzm = varargin{1}; | |
29 else | |
30 error('### Please input (<object>,<plist>)'); | |
31 end | |
32 | |
33 ssmout = ssm.initObjectWithSize(size(pzm,1),size(pzm,2)); | |
34 | |
35 for i_pzms=1:numel(pzm) | |
36 [A,B,C,D] = utils.math.pzmodel2SSMats(pzm(i_pzms)); | |
37 | |
38 ssmout(i_pzms).dmats = {D}; | |
39 ssmout(i_pzms).amats = {A}; | |
40 ssmout(i_pzms).bmats = {B}; | |
41 ssmout(i_pzms).cmats = {C}; | |
42 | |
43 ssmout(i_pzms).name = pzm(i_pzms).name; | |
44 ssmout(i_pzms).timestep = 0; | |
45 | |
46 inputstr = 'input'; | |
47 outputstr = 'output'; | |
48 ssstr = 'state'; | |
49 Nss = size(A,1); | |
50 | |
51 ssmout(i_pzms).inputs = ssmblock.makeBlocksWithData({inputstr}, [], {{inputstr}}, {pzm(i_pzms).iunits}, []); | |
52 ssmout(i_pzms).outputs = ssmblock.makeBlocksWithData({outputstr}, [], {{outputstr}}, {pzm(i_pzms).ounits}, []); | |
53 ssmout(i_pzms).states = ssmblock.makeBlocksWithSize(Nss, ssstr); | |
54 | |
55 ssmout(i_pzms).addHistory(ii, pl, {''}, pzm(i_pzms).hist); | |
56 | |
57 if ~strcmp(pl.find('name'),'None') | |
58 ssmout(i_pzms).name = pl.find('name'); | |
59 end | |
60 if ~strcmp(pl.find('description'),'') | |
61 ssmout(i_pzms).description = pl.find('description'); | |
62 end | |
63 | |
64 end | |
65 | |
66 | |
67 end |