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.html,v 1.14 2008/03/31 10:27:32 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 % MPOWER implements power operator for analysis objects.
0002 %
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 % DESCRIPTION: MPOWER implements power operator for analysis objects.
0006 %              computes b^c where b is an analysis object and c is either
0007 %              another analysis object or a constant.
0008 %
0009 % CALL:        a = a1^2
0010 %              a = a1^a2     % with a2.data.vals = scalar
0011 %
0012 % VERSION:     $Id: mpower.html,v 1.14 2008/03/31 10:27:32 hewitson Exp $
0013 %
0014 % The following call returns a parameter list object that contains the
0015 % default parameter values:
0016 %
0017 % >> pl = mpower(ao, 'Params')
0018 %
0019 % The following call returns a string that contains the routine CVS version:
0020 %
0021 % >> version = mpower(ao,'Version')
0022 %
0023 % The following call returns a string that contains the routine category:
0024 %
0025 % >> category = mpower(ao,'Category')
0026 %
0027 % HISTORY: 01-02-07 M Hewitson
0028 %             Creation
0029 %
0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0031 
0032 function b = mpower(varargin)
0033 
0034 ALGONAME = mfilename;
0035 VERSION  = '$Id: mpower.html,v 1.14 2008/03/31 10:27:32 hewitson Exp $';
0036 CATEGORY = 'Arithmetic Operator';
0037 
0038 %% Check if this is a call for parameters
0039 if nargin == 2
0040   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0041     in = char(varargin{2});
0042     if strcmp(in, 'Params')
0043       b = getDefaultPL();
0044       return
0045     elseif strcmp(in, 'Version')
0046       b = VERSION;
0047       return
0048     elseif strcmp(in, 'Category')
0049       b = CATEGORY;
0050       return
0051     end
0052   end
0053 end
0054 
0055 % Collect input ao's, plist's and ao variable names
0056 in_names = {};
0057 for ii = 1:nargin
0058   in_names{end+1} = inputname(ii);
0059 end
0060 
0061 [as, pl, invars] = collect_inputs(varargin, in_names);
0062 
0063 op = '^';
0064 
0065 [a1,a2,do] = aooperate(varargin, op);
0066 
0067 %--------- create output AO
0068 
0069 % make a new history object
0070 h = history(ALGONAME, VERSION, plist(), [a1.hist a2.hist]);
0071 h = set(h, 'invars', invars);
0072 
0073 % get names for output
0074 if isempty(char(invars{1}))
0075   n1 = a1.name;
0076 else
0077   n1 = char(invars{1});
0078 end
0079 if isempty(char(invars{2}))
0080   n2 = a2.name;
0081 else
0082   n2 = char(invars{2});
0083 end
0084 
0085 % make output analysis object
0086 b = ao(do, h);
0087 b = setnh(b, 'name', sprintf('%s %s %s', n1, op, n2));
0088 
0089 
0090 %% Get default params
0091 function pl_default = getDefaultPL()
0092 
0093   pl_default = plist();
0094 
0095 % END

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003