APPLYOPERATOR applys the given operator to the two input data objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: APPLYOPERATOR applys the given operator to the two input 2D data objects. CALL: d = applyoperator(d1, d2, pl) INPUTS: d1/2 - an ltpda_data object (cdata, tsdata, fsdata, xydata) pl - a plist of configuration options PARAMETERS: 'op' - the operator to apply, e.g. 'plus' M-FILE INFO: Get information about this methods by calling >> fsdata.getInfo('applyoperator') Get information about a specified set-plist by calling: >> fsdata.getInfo('applyoperator', 'set') VERSION: $Id: applyoperator.m,v 1.12 2008/09/04 15:29:30 ingo Exp $ HISTORY: 04-02-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % APPLYOPERATOR applys the given operator to the two input data objects. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: APPLYOPERATOR applys the given operator to the two input 0005 % 2D data objects. 0006 % 0007 % CALL: d = applyoperator(d1, d2, pl) 0008 % 0009 % INPUTS: d1/2 - an ltpda_data object (cdata, tsdata, fsdata, xydata) 0010 % pl - a plist of configuration options 0011 % 0012 % PARAMETERS: 'op' - the operator to apply, e.g. 'plus' 0013 % 0014 % M-FILE INFO: Get information about this methods by calling 0015 % >> fsdata.getInfo('applyoperator') 0016 % 0017 % Get information about a specified set-plist by calling: 0018 % >> fsdata.getInfo('applyoperator', 'set') 0019 % 0020 % VERSION: $Id: applyoperator.m,v 1.12 2008/09/04 15:29:30 ingo Exp $ 0021 % 0022 % HISTORY: 04-02-2007 M Hewitson 0023 % Creation 0024 % 0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0026 0027 function varargout = applyoperator(varargin) 0028 0029 %%% Check if this is a call for parameters 0030 if utils.helper.isinfocall(varargin{:}) 0031 varargout{1} = getInfo(varargin{3}); 0032 return 0033 end 0034 0035 % Get the objects we have in the correct order 0036 objs = []; 0037 for j=1:nargin 0038 if isa(varargin{j}, 'data2D') || isa(varargin{j}, 'cdata') 0039 objs = [objs {varargin{j}}]; 0040 end 0041 end 0042 0043 % Get data2D objects and plists 0044 [pl] = utils.helper.collect_objects(varargin(:), 'plist'); 0045 0046 % Combine with default plist 0047 pl = combine(pl, getDefaultPlist); 0048 0049 % Get the operator to apply 0050 op = find(pl, 'op'); 0051 0052 if numel(objs) ~= 2 0053 error('### data2D/applyoperator requires two input data objects to work on.'); 0054 end 0055 0056 %--------------- Add some rules here. 0057 % cdata 0058 % 1) time-base must match 0059 % 2) y dimensions must match or one must be a single value 0060 % 0061 0062 %%% Decide the type of the output object 0063 if isa(objs{1}, 'data2D') 0064 dout = objs{1}; 0065 y1 = dout.y; 0066 y2 = objs{2}.y; 0067 elseif isa(objs{2}, 'data2D') 0068 dout = objs{2}; 0069 y1 = objs{1}.y; 0070 y2 = dout.y; 0071 else 0072 dout = objs{1}; 0073 y1 = dout.y; 0074 y2 = objs{2}.y; 0075 end 0076 0077 %%% Change for the following operations the shape of the axis 0078 %%% if the shape is different 0079 if strcmp(op, 'minus') || ... 0080 strcmp(op, 'plus') || ... 0081 strcmp(op, 'rdivide') || ... 0082 strcmp(op, 'times') || ... 0083 strcmp(op, 'power') 0084 s1 = size(y1); 0085 s2 = size(y2); 0086 if s1(1) == 1 && s2(1) ~= 1 0087 y2 = y2.'; 0088 end 0089 if s1(2) == 1 && s2(2) ~= 1 0090 y2 = y2.'; 0091 end 0092 end 0093 0094 dout.setY(feval(op, y1, y2)); 0095 0096 varargout{1} = dout; 0097 end 0098 0099 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0100 % Local Functions % 0101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0102 0103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0104 % 0105 % FUNCTION: getInfo 0106 % 0107 % DESCRIPTION: Get Info Object 0108 % 0109 % HISTORY: 11-07-07 M Hewitson 0110 % Creation. 0111 % 0112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0113 0114 function ii = getInfo(varargin) 0115 if nargin == 1 && strcmpi(varargin{1}, 'None') 0116 sets = {}; 0117 pl = []; 0118 else 0119 sets = {'Default'}; 0120 pl = getDefaultPlist; 0121 end 0122 % Build info object 0123 ii = minfo(mfilename, 'data2D', '', utils.const.categories.internal, '$Id: applyoperator.m,v 1.12 2008/09/04 15:29:30 ingo Exp $', sets, pl); 0124 end 0125 0126 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0127 % 0128 % FUNCTION: getDefaultPlist 0129 % 0130 % DESCRIPTION: Get Default Plist 0131 % 0132 % HISTORY: 11-07-07 M Hewitson 0133 % Creation. 0134 % 0135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0136 0137 function pl = getDefaultPlist() 0138 pl = plist('op', ''); 0139 end