Mercurial > hg > ltpda
comparison m-toolbox/classes/@ssm/setParams.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 % SETPARAMS Sets the parameters of the model to the given plist. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: SETPARAMS Sets the params of the model to the given plist. | |
5 % | |
6 % CALL: obj = obj.setParameters(pl); | |
7 % | |
8 % <a href="matlab:utils.helper.displayMethodInfo('ssm', 'setParams')">Parameters Description</a> | |
9 % | |
10 % VERSION: $Id: setParams.m,v 1.10 2011/04/08 08:56:23 hewitson Exp $ | |
11 % | |
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
13 | |
14 function varargout = setParams(varargin) | |
15 | |
16 %% Check if this is a call for parameters | |
17 if utils.helper.isinfocall(varargin{:}) | |
18 varargout{1} = getInfo(varargin{3}); | |
19 return | |
20 end | |
21 | |
22 import utils.const.* | |
23 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); | |
24 | |
25 %% Collect input variable names | |
26 in_names = cell(size(varargin)); | |
27 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
28 | |
29 [ssms, ssm_invars, rest] = utils.helper.collect_objects(varargin(:), 'ssm', in_names); | |
30 [pl, invars2, rest] = utils.helper.collect_objects(rest(:), 'plist'); | |
31 if ~isempty(rest) | |
32 pl = combine(pl, plist(rest{:})); | |
33 end | |
34 pl = combine(pl, getDefaultPlist()); | |
35 | |
36 %%% Internal call: Only one object + don't look for a plist | |
37 internal = strcmp(varargin{end}, 'internal'); | |
38 | |
39 if numel(pl)>1 || isempty(pl) | |
40 error('### Please give one input plist'); | |
41 end | |
42 | |
43 outs = copy(ssms, nargout); | |
44 | |
45 %% Loop over the input ssm objects | |
46 for kk = 1:numel(outs) | |
47 ss = outs(kk); | |
48 ss.params = params; | |
49 if ~internal | |
50 % append history step | |
51 ss.addHistory(getInfo('None'), pl, ssm_invars(kk), ss.hist); | |
52 end | |
53 end % End loop over ssm objects | |
54 | |
55 | |
56 %% Set output | |
57 if nargout == numel(outs) | |
58 % List of outputs | |
59 for ii = 1:numel(outs) | |
60 varargout{ii} = outs(ii); | |
61 end | |
62 else | |
63 % Single output | |
64 varargout{1} = outs; | |
65 end | |
66 end | |
67 | |
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
69 % Local Functions % | |
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
71 | |
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
73 % | |
74 % FUNCTION: getInfo | |
75 % | |
76 % DESCRIPTION: Get Info Object | |
77 % | |
78 % HISTORY: 11-07-07 M Hewitson | |
79 % Creation. | |
80 % | |
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
82 | |
83 function ii = getInfo(varargin) | |
84 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
85 sets = {}; | |
86 pl = []; | |
87 else | |
88 sets = {'Default'}; | |
89 pl = getDefaultPlist; | |
90 end | |
91 % Build info object | |
92 ii = minfo(mfilename, 'ssm', 'ltpda', utils.const.categories.helper, '$Id: setParams.m,v 1.10 2011/04/08 08:56:23 hewitson Exp $', sets, pl); | |
93 end | |
94 | |
95 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
96 % | |
97 % FUNCTION: getDefaultPlist | |
98 % | |
99 % DESCRIPTION: Get Default Plist | |
100 % | |
101 % HISTORY: 11-07-07 M Hewitson | |
102 % Creation. | |
103 % | |
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
105 | |
106 function plo = getDefaultPlist() | |
107 plo = plist(); | |
108 | |
109 % params | |
110 p = param({'params', 'A plist containing the list of parameters.'}, {1, {plist}, paramValue.OPTIONAL}); | |
111 plo.append(p); | |
112 end | |
113 | |
114 | |
115 |