comparison m-toolbox/classes/@matrix/spsdSubtraction.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 % SPSDSUBTRACTION makes a sPSD-weighted least-square iterative fit
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SPSDSUBTRACTION makes a sPSD-weighted least-square iterative fit
5 %
6 % CALL: [MPest, aoResiduum, plOut, aoP, aoPini] = optSubtraction(mat_Y, mat_U);
7 % [MPest, aoResiduum, plOut, aoP, aoPini] = optSubtraction(mat_Y, mat_U, pl);
8 %
9 % The function finds the optimal M that minimizes the sum of the weighted sPSD of
10 % (mat_Y - M * mat_U)
11 %
12 % OUTPUTS: - MPest: output PEST object with parameter estimates
13 % - aoResiduum: residuum times series
14 % - plOut: plist containing data like the parameter estimates
15 % - aoP: last weight used in the optimization (fater last
16 % Maximization/Expectation step)
17 % - aoPini: initial weight used in the optimization (before first
18 % Maximization/Expectation step)
19 %
20 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'optSubtraction')">Parameters Description</a>
21 %
22 % VERSION : $Id: spsdSubtraction.m,v 1.1 2011/04/17 21:24:20 adrien Exp $
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24
25 function varargout = spsdSubtraction(varargin)
26
27 % use the caller is method flag
28 callerIsMethod = utils.helper.callerIsMethod;
29
30 % Check if this is a call for parameters
31 if utils.helper.isinfocall(varargin{:})
32 varargout{1} = getInfo(varargin{3});
33 return
34 end
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 if ~nargin>1
41 error('optSubtraction requires at two input matrix objects (less than two input arguments were provided!)')
42 end
43
44 %% retrieving the two input aos
45 [mat_in, mat_invars] = utils.helper.collect_objects(varargin(:), 'matrix', in_names);
46
47 if numel(mat_in)~=2
48 error('first two inputs should be two matrices of aos involved in the subtraction')
49 end
50
51 % Collect plist
52 pl = utils.helper.collect_objects(varargin(:), 'plist');
53
54 % Get default parameters
55 pl = combine(pl, getDefaultPlist);
56
57 %% getting ao arrays
58 ao_Y = mat_in(1).objs;
59 ao_U = mat_in(2).objs;
60
61 %% running the ao method
62 if nargout>2
63 [MPest, plOut, aoResiduum, aoP, aoPini] = optSubtraction(ao_Y, ao_U, pl);
64 matResiduum = matrix(aoResiduum);
65 matP = matrix(aoP);
66 matPini = matrix(aoPini);
67 else
68 [MPest, plOut] = optSubtraction(ao_Y, ao_U, pl);
69 end
70
71 %% collecting history
72 if callerIsMethod
73 % we don't need the history of the input
74 else
75 inhist = mat_in(:).hist;
76 end
77
78 %% adding history
79 if callerIsMethod
80 % we don't to set the history
81 else
82 MPest.addHistory(getInfo('None'), pl, mat_invars, inhist);
83 if nargout>2
84 matP.addHistory(getInfo('None'), pl, mat_invars, inhist);
85 matPini.addHistory(getInfo('None'), pl, mat_invars, inhist);
86 matResiduum.addHistory(getInfo('None'), pl, mat_invars, inhist);
87 end
88 end
89
90 %% return coefficients and hessian and Jfinal and powAvgWeight
91 varargout = {MPest, plOut, aoP, aoPini};
92
93 end
94
95
96
97 %--------------------------------------------------------------------------
98 % Get Info Object
99 %--------------------------------------------------------------------------
100 function ii = getInfo(varargin)
101 if nargin == 1 && strcmpi(varargin{1}, 'None')
102 sets = {};
103 pl = [];
104 else
105 sets = {'Default'};
106 pl = getDefaultPlist;
107 end
108 % Build info object
109 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.op, '$Id: spsdSubtraction.m,v 1.1 2011/04/17 21:24:20 adrien Exp $', sets, pl);
110 end
111
112 %--------------------------------------------------------------------------
113 % Get Default Plist
114 %--------------------------------------------------------------------------
115 function plout = getDefaultPlist()
116 persistent pl;
117 if exist('pl', 'var')==0 || isempty(pl)
118 pl = buildplist();
119 end
120 plout = pl;
121 end
122
123 function pl = buildplist()
124 pl = ssm.getInfo('ao/spsdSubtraction', 'Default').plists;
125 end
126
127