comparison m-toolbox/classes/@ssm/ssmFromDescription.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: ssmFromDescription
4 %
5 % DESCRIPTION: Construct a statespace model from a plist description
6 %
7 % CALL: see ssm, this function is private
8 %
9 % TODO: inplement multiple i/o when subassign function is done
10 %
11 % VERSION : '$Id: ssmFromDescription.m,v 1.33 2010/10/29 12:43:29 ingo Exp $';
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function sys = ssmFromDescription(pli)
16
17 VERSION = '$Id: ssmFromDescription.m,v 1.33 2010/10/29 12:43:29 ingo Exp $';
18
19 utils.helper.msg(utils.const.msg.MNAME, ['running ', mfilename]);
20
21 % get info
22 ii = ssm.getInfo('ssm', 'From Description');
23 % Set the method version string in the minfo object
24 ii.setMversion([VERSION '-->' ii.mversion]);
25
26 % Get default params
27 pl = combine(pli, ii.plists);
28 if ~isa(pl,'plist') % checking input type
29 error(['error because input is not a plist but a ', class(pl)]);
30 end
31
32 sys = ssm.initObjectWithSize(1,1);
33
34 % filling compulsory user defined fields
35 userfields = { 'name' 'timestep' 'amats' 'bmats' 'cmats' 'dmats' 'description'};
36
37 % other optional fields that may be used defined
38 otherfields = { 'params' 'inputs' 'outputs' 'states'};
39 dependentFields = {'statenames' 'inputnames' 'outputnames'};
40
41 for f = userfields
42 if ~isparam(pl, f{1})
43 display(['### ERROR : field in ssm named ''',f{1},''' must be user defined ###']);
44 display('### list of other compulsory user defined fields ###')
45 display(char(userfields))
46 display('### list of other optional user defined fields ###')
47 display(char(otherfields))
48 display('### list of other shortcuts ###')
49 display(char(dependentFields))
50 error(['see above message and lists ^^ ']);
51 end
52 end
53
54 % add history
55 sys.addHistory(ii, pl, {''}, []);
56
57 % Set other properties from the plist
58 for f = userfields
59 sys.(f{1})=find(pl, f{1});
60 end
61
62 for f = [otherfields dependentFields]
63 if isparam(pl, f{1})
64 if ~isempty(find(pl, f{1}))
65 sys.(f{1})=find(pl, f{1});
66 end
67 end
68 end
69
70 sys.validate;
71
72 end
73
74