comparison m-toolbox/classes/@ssm/getParameters.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 % getParameters returns parameter values for the given names.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: getParameters returns parameter values for the given
5 % names.
6 %
7 % CALL:
8 % vals = getParameters(sys, options)
9 %
10 % INPUTS:
11 % sys - ssm objects
12 % options - plist of options:
13 %
14 % OUTPUTS:
15 % vals - an array of values, 1 value for each of the specified
16 % names found in the model. For multiple input models, the
17 % output values will be a cell-array of numeric vectors,
18 % one cell per input system.
19 %
20 % <a href="matlab:utils.helper.displayMethodInfo('ssm', 'getParameters')">Parameters Description</a>
21 %
22 % VERSION: $Id: getParameters.m,v 1.10 2011/04/08 08:56:22 hewitson Exp $
23 %
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25 function varargout = getParameters(varargin)
26
27 %% starting initial checks
28 % Check if this is a call for parameters
29 if utils.helper.isinfocall(varargin{:})
30 varargout{1} = getInfo(varargin{3});
31 return
32 end
33
34 utils.helper.msg(utils.const.msg.MNAME, ['running ', mfilename]);
35
36 % Collect input variable names
37 in_names = cell(size(varargin));
38 for ii = 1:nargin, in_names{ii} = inputname(ii); end
39
40 % Collect all SSMs and options
41 [sys, ssm_invars, rest] = utils.helper.collect_objects(varargin(:), 'ssm', in_names);
42 [pl, pl_invars, rest] = utils.helper.collect_objects(rest(:), 'plist');
43 if ~isempty(rest)
44 pl = combine(pl, plist(rest{:}));
45 end
46 pl = combine(pl, getDefaultPlist());
47
48 %% processing input
49 paramNames = pl.find('names');
50 if ischar(paramNames)
51 paramNames = {paramNames};
52 elseif ~iscellstr(paramNames)
53 error('param names be a cellstr')
54 end
55
56 utils.helper.msg(utils.const.msg.PROC1, 'looking for:');
57 for jj=1:numel(paramNames)
58 utils.helper.msg(utils.const.msg.PROC1, ' %s', paramNames{jj});
59 end
60
61 %% Loop over systems
62 vals = cell(numel(sys),1);
63 for jj=1:numel(sys)
64 % loop over param names
65 svals = [];
66 for kk=1:numel(paramNames)
67 svals = find(sys(jj).params, paramNames{kk});
68 end
69 vals{jj} = svals;
70 end
71
72 if nargout == numel(vals)
73 varargout{:} = vals{:};
74 else
75 varargout{1} = vals;
76 end
77 end
78
79
80 %--------------------------------------------------------------------------
81 % Get Info Object
82 %--------------------------------------------------------------------------
83 function ii = getInfo(varargin)
84
85 if nargin == 1 && strcmpi(varargin{1}, 'None')
86 sets = {};
87 pl = [];
88 else
89 sets = {'Default'};
90 pl = getDefaultPlist;
91 end
92 % Build info object
93 ii = minfo(mfilename, 'ssm', 'ltpda', utils.const.categories.output, '$Id: getParameters.m,v 1.10 2011/04/08 08:56:22 hewitson Exp $', sets, pl);
94 end
95
96 %--------------------------------------------------------------------------
97 % Get Default Plist
98 %--------------------------------------------------------------------------
99 function pl = getDefaultPlist()
100 pl = plist();
101
102 p = param({'names', 'A cell-array of parameter names to get the values of.'}, {} );
103 pl.append(p);
104
105 end
106