TIMEDOMAINFIT uses lscov to fit a set of time-series AOs to a target time-series AO. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: TIMEDOMAINFIT uses lscov to fit a set of time-series AOs to a target time-series AO. CALL: [x stdx mse S] = timedomainfit(a1,a2,a3,..., pl) INPUTS: asN - a list of analysis objects containing the data to be fitted. The first input analysis object that contains time-series data is the target object. A linear combination of all other time-series AOs is fit to this target. pl - a parameter list OUTPUTS: x - cdata type analysis object containing the fitting coefficients stdx - estimated standard errors of x mse - mean squared error S - estimated covariance matrix of X M-FILE INFO: Get information about this methods by calling >> class.getInfo('timedomainfit') Get information about a specified set-plist by calling: >> class.getInfo('timedomainfit', 'set') VERSION: $Id: timedomainfit.m,v 1.6 2008/09/05 11:05:29 ingo Exp $ HISTORY: 01-03-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % TIMEDOMAINFIT uses lscov to fit a set of time-series AOs to a target time-series AO. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: TIMEDOMAINFIT uses lscov to fit a set of time-series AOs to 0005 % a target time-series AO. 0006 % 0007 % CALL: [x stdx mse S] = timedomainfit(a1,a2,a3,..., pl) 0008 % 0009 % INPUTS: asN - a list of analysis objects containing the data to be fitted. 0010 % The first input analysis object that contains time-series 0011 % data is the target object. A linear combination of all other 0012 % time-series AOs is fit to this target. 0013 % pl - a parameter list 0014 % 0015 % OUTPUTS: x - cdata type analysis object containing the fitting 0016 % coefficients 0017 % stdx - estimated standard errors of x 0018 % mse - mean squared error 0019 % S - estimated covariance matrix 0020 % of X 0021 % M-FILE INFO: Get information about this methods by calling 0022 % >> class.getInfo('timedomainfit') 0023 % 0024 % Get information about a specified set-plist by calling: 0025 % >> class.getInfo('timedomainfit', 'set') 0026 % 0027 % VERSION: $Id: timedomainfit.m,v 1.6 2008/09/05 11:05:29 ingo Exp $ 0028 % 0029 % HISTORY: 01-03-2007 M Hewitson 0030 % Creation 0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0032 0033 function varargout = timedomainfit(varargin) 0034 0035 %%% Check if this is a call for parameters 0036 if utils.helper.isinfocall(varargin{:}) 0037 varargout{1} = getInfo(varargin{3}); 0038 return 0039 end 0040 0041 import utils.const.* 0042 utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename); 0043 0044 %%% Collect input variable names 0045 in_names = cell(size(varargin)); 0046 for ii = 1:nargin,in_names{ii} = inputname(ii);end 0047 0048 %%% Collect all AOs 0049 [as, ao_invars, rest] = utils.helper.collect_objects(varargin(:), 'ao', in_names); 0050 [pli, pl_invars, rest] = utils.helper.collect_objects(rest, 'plist', in_names); 0051 0052 %%% Decide on a deep copy or a modify 0053 %%% REMARK: If you create a new AO (call the constructor) then 0054 %%% it is not necessay to copy the input-AOs !!!!!!!!!!!!!!!!!!!!!!!!! 0055 bs = copy(as, nargout); 0056 0057 %%% Combine plists 0058 pl = combine(pli, getDefaultPlist); 0059 % k = find(pl,'bin'); 0060 %%% go through analysis objects 0061 x = []; 0062 for kk = 1:numel(bs) 0063 %%%%%%%%%% some calculations %%%%%%%%%% 0064 if ~isreal(bs(kk).data.y) 0065 error('### I only work with real time-series at the moment.'); 0066 end 0067 % get data out 0068 x(:,kk) = bs(kk).data.y; 0069 0070 end 0071 % Fit 0072 [m,n] = size(x); 0073 [coef, stdx, mse, S] = lscov(x(:,2:n),x(:,1)); 0074 0075 utils.helper.msg(msg.PROC1, 'got coefficients: %s', num2str(coef.')); 0076 %%create new ao 0077 % bs(kk).data.setY(ydata_new); 0078 0079 coef = ao([coef']); 0080 stdx = ao(stdx); 0081 mse = ao(mse); 0082 S = ao(S); 0083 0084 coef.addHistory(getInfo('None'), pl, ao_invars(kk),coef.hist); 0085 stdx.addHistory(getInfo('None'), pl, ao_invars(kk),stdx.hist); 0086 mse.addHistory(getInfo('None'), pl, ao_invars(kk),mse.hist); 0087 S.addHistory(getInfo('None'), pl, ao_invars(kk),S.hist); 0088 % bs(kk).data.setY(some_new_data); 0089 % bs(kk).data.setFs(new_fs); 0090 % bs(kk).data.setXunits(new_xunits); 0091 % bd(kk).setName('my name'); 0092 0093 %%% Set Name 0094 % bs(kk).setName('new name', 'internal'); 0095 0096 %%% Add History 0097 % bs(kk).addHistory(getInfo('None'), pl, ao_invars(kk), bs(kk).hist); 0098 0099 0100 0101 %%% Reshape the output to the same size of the input 0102 varargout{1} = coef; 0103 varargout{2} = stdx; 0104 varargout{3} = mse; 0105 varargout{4} = S; 0106 end 0107 0108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0109 % Local Functions % 0110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0111 0112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0113 % 0114 % FUNCTION: getInfo 0115 % 0116 % DESCRIPTION: Get Info Object 0117 % 0118 % HISTORY: 11-07-07 M Hewitson 0119 % Creation. 0120 % 0121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0122 0123 function ii = getInfo(varargin) 0124 if nargin == 1 && strcmpi(varargin{1}, 'None') 0125 sets = {}; 0126 pl = []; 0127 else 0128 sets = {'Default'}; 0129 pl = getDefaultPlist; 0130 end 0131 % Build info object 0132 ii = minfo(mfilename, 'ao', '', utils.const.categories.sigproc, '$Id: timedomainfit.m,v 1.6 2008/09/05 11:05:29 ingo Exp $', sets, pl); 0133 end 0134 0135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0136 % 0137 % FUNCTION: getDefaultPlist 0138 % 0139 % DESCRIPTION: Get Default Plist 0140 % 0141 % HISTORY: 11-07-07 M Hewitson 0142 % Creation. 0143 % 0144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0145 0146 function plo = getDefaultPlist() 0147 plo = plist(); 0148 end 0149 0150