Mercurial > hg > ltpda
comparison m-toolbox/classes/@ssm/optimiseForFitting.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 % OPTIMISEFORFITTING reduces the system matrices to doubles and strings. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % | |
5 % DESCRIPTION: OPTIMISEFORFITTING reduces the system matrices to doubles | |
6 % and strings. | |
7 % | |
8 % CALL: [ssm] = optimiseForFitting(ssm, pl); | |
9 % | |
10 % INPUTS : | |
11 % ssm - a ssm object | |
12 % pl - an option plist | |
13 % | |
14 % | |
15 % OUTPUTS: | |
16 % The output array are of size Nsys*Noptions | |
17 % sys_out - (array of) ssm objects without the specified information | |
18 % | |
19 % | |
20 % <a href="matlab:utils.helper.displayMethodInfo('ssm', 'simplify')">Parameters Description</a> | |
21 % | |
22 % VERSION: $Id: optimiseForFitting.m,v 1.4 2011/04/08 08:56:23 hewitson Exp $ | |
23 % | |
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
25 | |
26 function varargout = optimiseForFitting(varargin) | |
27 | |
28 import utils.const.* | |
29 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); | |
30 %% starting initial checks | |
31 | |
32 % Check if this is a call for parameters | |
33 if utils.helper.isinfocall(varargin{:}) | |
34 varargout{1} = getInfo(varargin{3}); | |
35 return | |
36 end | |
37 | |
38 % Collect input variable names | |
39 in_names = cell(size(varargin)); | |
40 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
41 | |
42 % Collect all SSMs and plists | |
43 [sys, ssm_invars, rest] = utils.helper.collect_objects(varargin(:), 'ssm', in_names); | |
44 [pl, invars2, rest] = utils.helper.collect_objects(rest(:), 'plist'); | |
45 if ~isempty(rest) | |
46 pl = combine(pl, plist(rest{:})); | |
47 end | |
48 pl = combine(pl, getDefaultPlist); | |
49 | |
50 Nsys = numel(sys); | |
51 if Nsys ~= 1 | |
52 error('### Please input (only) one SSM model'); | |
53 end | |
54 | |
55 % Decide on a deep copy or a modify, depending on the output | |
56 sys = copy(sys, nargout); | |
57 | |
58 %% begin function body | |
59 | |
60 % Loop over input systems | |
61 for i_sys=1:Nsys | |
62 | |
63 % amats | |
64 for kk=1:numel(sys(i_sys).amats) | |
65 sys(i_sys).amats{kk} = simplifyMatrix(sys(i_sys).amats{kk}); | |
66 end | |
67 | |
68 % bmats | |
69 for kk=1:numel(sys(i_sys).bmats) | |
70 sys(i_sys).bmats{kk} = simplifyMatrix(sys(i_sys).bmats{kk}); | |
71 end | |
72 | |
73 % cmats | |
74 for kk=1:numel(sys(i_sys).cmats) | |
75 sys(i_sys).cmats{kk} = simplifyMatrix(sys(i_sys).cmats{kk}); | |
76 end | |
77 | |
78 % dmats | |
79 for kk=1:numel(sys(i_sys).dmats) | |
80 sys(i_sys).dmats{kk} = simplifyMatrix(sys(i_sys).dmats{kk}); | |
81 end | |
82 | |
83 sys(i_sys).clearAllUnits; | |
84 sys(i_sys).clearNumParams; | |
85 | |
86 % updating size fields | |
87 sys(i_sys).addHistory(getInfo('None'), pl , ssm_invars(i_sys), sys(i_sys).hist ); | |
88 end | |
89 | |
90 if nargout == numel(sys) | |
91 for ii = 1:numel(sys) | |
92 varargout{ii} = sys(ii); | |
93 end | |
94 else | |
95 varargout{1} = sys; | |
96 end | |
97 end | |
98 | |
99 | |
100 function m = simplifyMatrix(m) | |
101 try | |
102 m = eval(m); | |
103 end | |
104 if ~isnumeric(m) | |
105 m = char(m); | |
106 end | |
107 end | |
108 | |
109 %-------------------------------------------------------------------------- | |
110 % Get Info Object | |
111 %-------------------------------------------------------------------------- | |
112 function ii = getInfo(varargin) | |
113 | |
114 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
115 sets = {}; | |
116 pl = []; | |
117 else | |
118 sets = {'Default'}; | |
119 pl = getDefaultPlist; | |
120 end | |
121 % Build info object | |
122 ii = minfo(mfilename, 'ssm', 'ltpda', utils.const.categories.op, '$Id: optimiseForFitting.m,v 1.4 2011/04/08 08:56:23 hewitson Exp $', sets, pl); | |
123 end | |
124 | |
125 %-------------------------------------------------------------------------- | |
126 % Get Default Plist | |
127 %-------------------------------------------------------------------------- | |
128 function pl = getDefaultPlist() | |
129 pl = plist(); | |
130 end | |
131 |