Home > classes > @ao > mpower.m

mpower

PURPOSE ^

MPOWER implements power operator for analysis objects.

SYNOPSIS ^

function b = mpower(varargin)

DESCRIPTION ^

 MPOWER implements power operator for analysis objects.

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

 DESCRIPTION: MPOWER implements power operator for analysis objects.
              computes b^c where b is an analysis object and c is either
              another analysis object or a constant.

 CALL:        a = a1^2
              a = a1^a2     % with a2.data.vals = scalar

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

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

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

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

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

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

 >> category = mpower(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 = mpower(varargin)
0002 % MPOWER implements power operator for analysis objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: MPOWER implements power operator for analysis objects.
0007 %              computes b^c where b is an analysis object and c is either
0008 %              another analysis object or a constant.
0009 %
0010 % CALL:        a = a1^2
0011 %              a = a1^a2     % with a2.data.vals = scalar
0012 %
0013 % VERSION:     $Id: mpower.m,v 1.13 2008/02/13 18:35:22 hewitson Exp $
0014 %
0015 % The following call returns a parameter list object that contains the
0016 % default parameter values:
0017 %
0018 % >> pl = mpower(ao, 'Params')
0019 %
0020 % The following call returns a string that contains the routine CVS version:
0021 %
0022 % >> version = mpower(ao,'Version')
0023 %
0024 % The following call returns a string that contains the routine category:
0025 %
0026 % >> category = mpower(ao,'Category')
0027 %
0028 % HISTORY: 01-02-07 M Hewitson
0029 %             Creation
0030 %
0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 
0033 ALGONAME = mfilename;
0034 VERSION  = '$Id: mpower.m,v 1.13 2008/02/13 18:35:22 hewitson Exp $';
0035 CATEGORY = 'Arithmetic Operator';
0036 
0037 %% Check if this is a call for parameters
0038 if nargin == 2
0039   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0040     in = char(varargin{2});
0041     if strcmp(in, 'Params')
0042       b = getDefaultPL();
0043       return
0044     elseif strcmp(in, 'Version')
0045       b = VERSION;
0046       return
0047     elseif strcmp(in, 'Category')
0048       b = CATEGORY;
0049       return
0050     end
0051   end
0052 end
0053 
0054 %% capture input variable names
0055 invars = {};
0056 for j=1:nargin
0057   iname = inputname(j);
0058   if isempty(iname) & isnumeric(varargin{j})
0059     iname = num2str(varargin{j});
0060   elseif isempty(iname) & ischar(varargin{j})
0061     iname = varargin{j};
0062   end
0063   invars = [invars cellstr(iname)];
0064 end
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 % make output analysis object
0089 % op = op(2:end);
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 
0100 % END

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