APPLYMETHOD applys the given method to the input 2D data. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: APPLYMETHOD applys the given method to the input 2D data. CALL: d = applymethod(d, pl) INPUTS: d - a cdata object pl - a plist of configuration options PARAMETERS: 'method' - the method to apply to the data 'dim' - the dimension of the chosen vector to apply the method to. This is necessary for functions like mean() when applied to matrices held in cdata objects. For tsdata, fsdata or xydata, this option has no effect. [default: 1] 'option' - any additional option to pass to the method. M-FILE INFO: Get information about this methods by calling >> cdata.getInfo('applymethod') Get information about a specified set-plist by calling: >> cdata.getInfo('applymethod', 'None') VERSION: $Id: applymethod.m,v 1.4 2008/09/04 15:29:30 ingo Exp $ HISTORY: 04-02-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % APPLYMETHOD applys the given method to the input 2D data. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: APPLYMETHOD applys the given method to the input 2D data. 0005 % 0006 % CALL: 0007 % d = applymethod(d, pl) 0008 % 0009 % INPUTS: 0010 % d - a cdata object 0011 % pl - a plist of configuration options 0012 % 0013 % PARAMETERS: 0014 % 0015 % 'method' - the method to apply to the data 0016 % 'dim' - the dimension of the chosen vector to apply the method 0017 % to. This is necessary for functions like mean() when 0018 % applied to matrices held in cdata objects. For tsdata, 0019 % fsdata or xydata, this option has no effect. 0020 % [default: 1] 0021 % 'option' - any additional option to pass to the method. 0022 % 0023 % M-FILE INFO: Get information about this methods by calling 0024 % >> cdata.getInfo('applymethod') 0025 % 0026 % Get information about a specified set-plist by calling: 0027 % >> cdata.getInfo('applymethod', 'None') 0028 % 0029 % VERSION: $Id: applymethod.m,v 1.4 2008/09/04 15:29:30 ingo Exp $ 0030 % 0031 % HISTORY: 04-02-2007 M Hewitson 0032 % Creation 0033 % 0034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0035 0036 function varargout = applymethod(varargin) 0037 0038 %%% Check if this is a call for parameters 0039 if utils.helper.isinfocall(varargin{:}) 0040 varargout{1} = getInfo(varargin{3}); 0041 return 0042 end 0043 0044 % Get data2D objects and plists 0045 [ds, ds_invars] = utils.helper.collect_objects(varargin(:), 'cdata'); 0046 [pl, pl_invars] = utils.helper.collect_objects(varargin(:), 'plist'); 0047 0048 % Combine with default plist 0049 pl = combine(pl, getDefaultPlist); 0050 0051 % Get the method to apply 0052 method = find(pl, 'method'); 0053 % Get the dimension to operate along 0054 dim = find(pl, 'dim'); 0055 % Get any additional option 0056 opt = find(pl, 'option'); 0057 0058 % Loop over data objects 0059 for jj=1:numel(ds) 0060 ds(jj).y = apply(ds(jj).y, method, dim, opt); 0061 end 0062 0063 % Set outputs 0064 varargout{1} = ds; 0065 0066 end 0067 0068 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0069 % Local Functions % 0070 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0071 0072 %----------------------------------------------- 0073 % Apply method to the vector v 0074 %----------------------------------------------- 0075 function v = apply(v, method, dim, opt) 0076 if ~isempty(dim) && ~isempty(opt) 0077 % User supplied a dimension and an option 0078 v = feval(method, v, dim, opt); 0079 elseif ~isempty(dim) 0080 % User supplied only a dimension 0081 v = feval(method, v, dim); 0082 elseif ~isempty(opt) 0083 % User supplied only an option 0084 v = feval(method, v, opt); 0085 else 0086 % User supplied only a method 0087 v = feval(method, v); 0088 end 0089 end 0090 0091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0092 % 0093 % FUNCTION: getInfo 0094 % 0095 % DESCRIPTION: Get Info Object 0096 % 0097 % HISTORY: 11-07-07 M Hewitson 0098 % Creation. 0099 % 0100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0101 0102 function ii = getInfo(varargin) 0103 if nargin == 1 && strcmpi(varargin{1}, 'None') 0104 sets = {}; 0105 pl = []; 0106 else 0107 sets = {'Default'}; 0108 pl = getDefaultPlist; 0109 end 0110 % Build info object 0111 ii = minfo(mfilename, 'cdata', '', utils.const.categories.internal, '$Id: applymethod.m,v 1.4 2008/09/04 15:29:30 ingo Exp $', sets, pl); 0112 end 0113 0114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0115 % 0116 % FUNCTION: getDefaultPlist 0117 % 0118 % DESCRIPTION: Get Default Plist 0119 % 0120 % HISTORY: 11-07-07 M Hewitson 0121 % Creation. 0122 % 0123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0124 0125 %----------------------------------------------- 0126 % Default plist 0127 %----------------------------------------------- 0128 function pl = getDefaultPlist() 0129 pl = plist('method', '', 'dim', [], 'option', ''); 0130 end 0131