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 2D data object (tsdata, fsdata, xydata) pl - a plist of configuration options PARAMETERS: 'method' - the method to apply to the data 'axis' - which axis vector to apply the method to. Possible values are: 'X', 'Y', 'XY' [default: 'Y'] '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 >> fsdata.getInfo('applymethod') Get information about a specified set-plist by calling: >> fsdata.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: d = applymethod(d, pl) 0007 % 0008 % INPUTS: d - a 2D data object (tsdata, fsdata, xydata) 0009 % pl - a plist of configuration options 0010 % 0011 % PARAMETERS: 0012 % 0013 % 'method' - the method to apply to the data 0014 % 'axis' - which axis vector to apply the method to. Possible values 0015 % are: 'X', 'Y', 'XY' [default: 'Y'] 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 % >> fsdata.getInfo('applymethod') 0025 % 0026 % Get information about a specified set-plist by calling: 0027 % >> fsdata.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 = utils.helper.collect_objects(varargin(:), 'data2D'); 0046 pl = 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 axis we are dealing with 0054 axis = find(pl, 'axis'); 0055 % Get the dimension to operate along 0056 dim = find(pl, 'dim'); 0057 % Get any additional option 0058 opt = find(pl, 'option'); 0059 0060 % Loop over data objects 0061 for jj=1:numel(ds) 0062 switch upper(axis) 0063 case 'X' 0064 ds(jj).x = apply(ds(jj).getX, method, dim, opt); 0065 case 'Y' 0066 ds(jj).y = apply(ds(jj).y, method, dim, opt); 0067 case 'XY' 0068 ds(jj).x = apply(ds(jj).getX, method, dim, opt); 0069 ds(jj).y = apply(ds(jj).y, method, dim, opt); 0070 otherwise 0071 error('### Unknown axis to operate on.'); 0072 end 0073 end 0074 0075 % Set outputs 0076 varargout{1} = ds; 0077 end 0078 0079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0080 % Local Functions % 0081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0082 0083 %----------------------------------------------- 0084 % Apply method to the vector v 0085 %----------------------------------------------- 0086 function v = apply(v, method, dim, opt) 0087 if ~isempty(dim) && ~isempty(opt) 0088 % User supplied a dimension and an option 0089 v = feval(method, v, dim, opt); 0090 elseif ~isempty(dim) 0091 % User supplied only a dimension 0092 v = feval(method, v, dim); 0093 elseif ~isempty(opt) 0094 % User supplied only an option 0095 v = feval(method, v, opt); 0096 else 0097 % User supplied only a method 0098 v = feval(method, v); 0099 end 0100 end 0101 0102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0103 % 0104 % FUNCTION: getInfo 0105 % 0106 % DESCRIPTION: Get Info Object 0107 % 0108 % HISTORY: 11-07-07 M Hewitson 0109 % Creation. 0110 % 0111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0112 0113 function ii = getInfo(varargin) 0114 if nargin == 1 && strcmpi(varargin{1}, 'None') 0115 sets = {}; 0116 pl = []; 0117 else 0118 sets = {'Default'}; 0119 pl = getDefaultPlist; 0120 end 0121 % Build info object 0122 ii = minfo(mfilename, 'data2D', '', utils.const.categories.internal, '$Id: applymethod.m,v 1.4 2008/09/04 15:29:30 ingo Exp $', sets, pl); 0123 end 0124 0125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0126 % 0127 % FUNCTION: getDefaultPlist 0128 % 0129 % DESCRIPTION: Get Default Plist 0130 % 0131 % HISTORY: 11-07-07 M Hewitson 0132 % Creation. 0133 % 0134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0135 0136 function pl = getDefaultPlist() 0137 pl = plist('method', '', 'axis', 'y', 'dim', [], 'option', ''); 0138 end 0139