Mercurial > hg > ltpda
comparison m-toolbox/classes/@ssm/subsParameters.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 % SUBSPARAMETERS enables to substitute symbolic patameters | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: SUBSPARAMETERS enables to modify and substitute parameters | |
5 % | |
6 % CALL: varargout = subsParameters(varargin) | |
7 % [sys_out] = subsParameters(sys_out, options) | |
8 % | |
9 % <a href="matlab:utils.helper.displayMethodInfo('ssm', 'subsParameters')">Parameters Description</a> | |
10 % | |
11 % VERSION: $Id: subsParameters.m,v 1.14 2011/04/08 08:56:22 hewitson Exp $ | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 | |
15 | |
16 function varargout = subsParameters(varargin) | |
17 | |
18 callerIsMethod = utils.helper.callerIsMethod; | |
19 | |
20 % Check if this is a call for parameters | |
21 if utils.helper.isinfocall(varargin{:}) | |
22 varargout{1} = getInfo(varargin{3}); | |
23 return | |
24 end | |
25 | |
26 if callerIsMethod | |
27 % assume call is subsParameters(sys, pl) | |
28 sys = varargin{1}; | |
29 pl = varargin{2}; | |
30 else | |
31 | |
32 | |
33 % starting initial checks | |
34 | |
35 % Collect input variable names | |
36 in_names = cell(size(varargin)); | |
37 for ii = 1:nargin, in_names{ii} = inputname(ii); end | |
38 | |
39 % Collect all SSMs and options | |
40 [sys, ssm_invars, rest] = utils.helper.collect_objects(varargin(:), 'ssm', in_names); | |
41 [pl, pl_invars, rest] = utils.helper.collect_objects(rest(:), 'plist'); | |
42 if ~isempty(rest) | |
43 pl = combine(pl, plist(rest{:})); | |
44 end | |
45 pl = combine(pl, getDefaultPlist); | |
46 end | |
47 | |
48 | |
49 % processing input | |
50 subsnames = pl.find('names'); | |
51 if ischar(subsnames) | |
52 subsnames = {subsnames}; | |
53 elseif ~iscellstr(subsnames) | |
54 error('param names be a cellstr') | |
55 end | |
56 | |
57 % Decide on a deep copy or a modify, depending on the output | |
58 sys_out = copy(sys, nargout); | |
59 Nsys = numel(sys); | |
60 | |
61 for i_sys = 1:Nsys | |
62 sys_out(i_sys).doSubsParameters(subsnames, callerIsMethod); | |
63 if ~callerIsMethod | |
64 sys_out(i_sys).addHistory(getInfo('None'), pl, ssm_invars(i_sys), sys_out(i_sys).hist ); | |
65 end | |
66 end | |
67 if nargout == numel(sys_out) | |
68 for ii = 1:numel(sys_out) | |
69 varargout{ii} = sys_out(ii); | |
70 end | |
71 else | |
72 varargout{1} = sys_out; | |
73 end | |
74 end | |
75 | |
76 | |
77 %-------------------------------------------------------------------------- | |
78 % Get Info Object | |
79 %-------------------------------------------------------------------------- | |
80 function ii = getInfo(varargin) | |
81 | |
82 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
83 sets = {}; | |
84 pl = []; | |
85 else | |
86 sets = {'Default'}; | |
87 pl = getDefaultPlist; | |
88 end | |
89 % Build info object | |
90 ii = minfo(mfilename, 'ssm', 'ltpda', utils.const.categories.op, '$Id: subsParameters.m,v 1.14 2011/04/08 08:56:22 hewitson Exp $', sets, pl); | |
91 end | |
92 | |
93 %-------------------------------------------------------------------------- | |
94 % Get Default Plist | |
95 %-------------------------------------------------------------------------- | |
96 function pl = getDefaultPlist() | |
97 pl = plist(); | |
98 | |
99 p = param({'names', 'A cell-array of parameter names for substitution.'}, {}); | |
100 pl.append(p); | |
101 end | |
102 |