comparison m-toolbox/classes/@ssm/addParameters.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 % ADDPARAMETERS Adds the parameters to the model.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: ADDPARAMETERS Adds the parameters to the (array of) model.
5 % Parameters are combined to the ones in the field 'params'
6 %
7 % CALL: obj = obj.addParameters('key1', val1, 'key2', val2);
8 % obj = obj.addParameters(plist);
9 %
10 % <a href="matlab:utils.helper.displayMethodInfo('ssm', 'addParameters')">Parameters Description</a>
11 %
12 % VERSION: $Id: addParameters.m,v 1.14 2011/04/08 08:56:23 hewitson Exp $
13 %
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15
16 function varargout = addParameters(varargin)
17
18 %% Check if this is a call for parameters
19 if utils.helper.isinfocall(varargin{:})
20 varargout{1} = getInfo(varargin{3});
21 return
22 end
23
24 %% send starting message
25 import utils.const.*
26 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
27
28 %% collecting input
29 in_names = cell(size(varargin));
30 for ii = 1:nargin,in_names{ii} = inputname(ii);end
31
32 [ssms, ssm_invars, rest] = utils.helper.collect_objects(varargin(:), 'ssm', in_names);
33 [pl, pl_invars, rest] = utils.helper.collect_objects(rest(:), 'plist', in_names); %#ok<ASGLU>
34 if ~isempty(rest)
35 pl = combine(pl, plist(rest{:}));
36 end
37 pl = combine(pl, getDefaultPlist());
38
39 ssmouts = copy(ssms, nargout);
40
41 %% Loop over the input ssm objects
42 for kk = 1:numel(ssmouts)
43 ssmouts(kk).params = pl.combine(ssmouts(kk).params);
44 % append history step
45 ssmouts(kk).addHistory(getInfo('None'), pl, ssm_invars(kk), ssmouts(kk).hist);
46 end % End loop over ssm objects
47
48
49 %% Set output depending on nargout
50 if nargout == numel(ssmouts)
51 for i=1:nargout
52 varargout{i} = ssmouts(i);
53 end
54 else
55 varargout{1} = ssmouts;
56 end
57 end
58
59 %--------------------------------------------------------------------------
60 % Get Info Object
61 %--------------------------------------------------------------------------
62 function ii = getInfo(varargin)
63
64 if nargin == 1 && strcmpi(varargin{1}, 'None')
65 sets = {};
66 pl = [];
67 else
68 sets = {'Default'};
69 pl = getDefaultPlist;
70 end
71 % Build info object
72 ii = minfo(mfilename, 'ssm', 'ltpda', utils.const.categories.helper, '$Id: addParameters.m,v 1.14 2011/04/08 08:56:23 hewitson Exp $', sets, pl);
73 end
74
75 %--------------------------------------------------------------------------
76 % Get Default Plist
77 %--------------------------------------------------------------------------
78 function pl = getDefaultPlist()
79 pl = plist();
80 end
81
82