Home > classes > @cdata > applyoperator.m

applyoperator

PURPOSE ^

APPLYOPERATOR applys the given operator to the two input data objects.

SYNOPSIS ^

function varargout = applyoperator(varargin)

DESCRIPTION ^

 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
              >> cdata.getInfo('applyoperator')

              Get information about a specified set-plist by calling:
              >> cdata.getInfo('applyoperator', 'set')

 VERSION:     $Id: applyoperator.m,v 1.8 2008/09/04 15:29:30 ingo Exp $

 HISTORY:     04-02-2007 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

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 %              >> cdata.getInfo('applyoperator')
0016 %
0017 %              Get information about a specified set-plist by calling:
0018 %              >> cdata.getInfo('applyoperator', 'set')
0019 %
0020 % VERSION:     $Id: applyoperator.m,v 1.8 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('### cdata/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     dout.setY(feval(op, dout.y, objs{2}.y));
0066   elseif isa(objs{2}, 'data2D')
0067     dout = objs{2};
0068     dout.setY(feval(op, objs{1}.y, dout.y));
0069   else
0070     dout = objs{1};
0071     dout.setY(feval(op, dout.y, objs{2}.y));
0072   end
0073 
0074   varargout{1} = dout;
0075 end
0076 
0077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0078 %                               Local Functions                               %
0079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0080 
0081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0082 %
0083 % FUNCTION:    getInfo
0084 %
0085 % DESCRIPTION: Get Info Object
0086 %
0087 % HISTORY:     11-07-07 M Hewitson
0088 %                Creation.
0089 %
0090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0091 
0092 function ii = getInfo(varargin)
0093   if nargin == 1 && strcmpi(varargin{1}, 'None')
0094     sets = {};
0095     pl   = [];
0096   else
0097     sets = {'Default'};
0098     pl   = getDefaultPlist;
0099   end
0100   % Build info object
0101   ii = minfo(mfilename, 'cdata', '', utils.const.categories.internal, '$Id: applyoperator.m,v 1.8 2008/09/04 15:29:30 ingo Exp $', sets, pl);
0102 end
0103 
0104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0105 %
0106 % FUNCTION:    getDefaultPlist
0107 %
0108 % DESCRIPTION: Get Default Plist
0109 %
0110 % HISTORY:     11-07-07 M Hewitson
0111 %                Creation.
0112 %
0113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0114 
0115 function pl = getDefaultPlist()
0116   pl = plist('op', '');
0117 end

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003