Home > classes > @ao > plus.m

plus

PURPOSE ^

PLUS implements addition operator for two analysis objects.

SYNOPSIS ^

function b = plus(varargin)

DESCRIPTION ^

 PLUS implements addition operator for two analysis objects.

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

 DESCRIPTION: PLUS implements addition operator for two analysis objects.

 CALL:        a = a1+scalar
              a = a1+a2

 VERSION:     $Id: plus.m,v 1.16 2008/02/13 18:35:22 hewitson Exp $

 The following call returns a parameter list object that contains the
 default parameter values:

 >> pl = plus(ao, 'Params')

 The following call returns a string that contains the routine CVS version:

 >> version = plus(ao,'Version')

 The following call returns a string that contains the routine category:

 >> category = plus(ao,'Category')

 HISTORY: 01-02-07 M Hewitson
             Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function b = plus(varargin)
0002 % PLUS implements addition operator for two analysis objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: PLUS implements addition operator for two analysis objects.
0007 %
0008 % CALL:        a = a1+scalar
0009 %              a = a1+a2
0010 %
0011 % VERSION:     $Id: plus.m,v 1.16 2008/02/13 18:35:22 hewitson Exp $
0012 %
0013 % The following call returns a parameter list object that contains the
0014 % default parameter values:
0015 %
0016 % >> pl = plus(ao, 'Params')
0017 %
0018 % The following call returns a string that contains the routine CVS version:
0019 %
0020 % >> version = plus(ao,'Version')
0021 %
0022 % The following call returns a string that contains the routine category:
0023 %
0024 % >> category = plus(ao,'Category')
0025 %
0026 % HISTORY: 01-02-07 M Hewitson
0027 %             Creation
0028 %
0029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0030 
0031 VERSION = '$Id: plus.m,v 1.16 2008/02/13 18:35:22 hewitson Exp $';
0032 CATEGORY = 'Arithmetic Operator';
0033 
0034 %% Check if this is a call for parameters
0035 if nargin == 2
0036   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0037     in = char(varargin{2});
0038     if strcmp(in, 'Params')
0039       b = getDefaultPL();
0040       return
0041     elseif strcmp(in, 'Version')
0042       b = VERSION;
0043       return
0044     elseif strcmp(in, 'Category')
0045       b = CATEGORY;
0046       return
0047     end
0048   end
0049 end
0050 
0051 %% capture input variable names
0052 invars = {};
0053 for j=1:nargin
0054   iname = inputname(j);
0055   if isempty(iname) && isnumeric(varargin{j})
0056     iname = num2str(varargin{j});
0057   elseif isempty(iname) && ischar(varargin{j})
0058     iname = varargin{j};
0059   end
0060   invars = [invars cellstr(iname)];
0061 end
0062 
0063 ALGONAME = mfilename;
0064 VERSION  = '$Id: plus.m,v 1.16 2008/02/13 18:35:22 hewitson Exp $';
0065 
0066 op = '+';
0067 
0068 [a1,a2,do] = aooperate(varargin, op);
0069 
0070 %--------- create output AO
0071 
0072 % make a new history object
0073 h = history(ALGONAME, VERSION, plist(), [a1.hist a2.hist]);
0074 h = set(h, 'invars', invars);
0075 
0076 % get names for output
0077 if isempty(char(invars{1}))
0078   n1 = a1.name;
0079 else
0080   n1 = char(invars{1});
0081 end
0082 if isempty(char(invars{2}))
0083   n2 = a2.name;
0084 else
0085   n2 = char(invars{2});
0086 end
0087 
0088 
0089 % make output analysis object
0090 b = ao(do, h);
0091 b = setnh(b, 'name', sprintf('%s %s %s', n1, op, n2));
0092 
0093 
0094 %% Get default params
0095 function pl_default = getDefaultPL()
0096 
0097   pl_default = plist();
0098 
0099 % END

Generated on Tue 26-Feb-2008 10:52:52 by m2html © 2003