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