Home > classes > @ao > compute.m

compute

PURPOSE ^

COMPUTE performs the given operations on the input AOs.

SYNOPSIS ^

function varargout = compute(varargin)

DESCRIPTION ^

 COMPUTE performs the given operations on the input AOs.

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

 DESCRIPTION: COMPUTE performs the given operations on the input AOs.

 CALL:        b = compute(a)
              b = compute(a, pl)
              b = compute(a, 'a(1) + a(2)./a(3)')
              b = compute(a, {'a(1) + a(2)./a(3)', 'log10(a(1))'})

 PARAMETERS:  'Operations' - a string array describing the operations to
                             be performed. The input AOs are collected
                             together into a vector called 'a' and as
                             such should be so represented in your
                             operation description.
 
 If no operation is input, then the output is just a copy of the inputs.

 EXAMPLES:

 1)  Add the two AOs, x and y, together
 
    >> b = compute(x,y, plist('Operations', 'a(1) + a(2)'))
 or
    >> b = compute(x,y, 'a(1) + a(2)')
 
 2) Perform two operations such that the output, b, contains two AOs
 
    >> b = compute([x y], z, plist('Operations', {'2.*a(3)./a(1)', 'a(2)-a(1)'}))

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

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

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

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

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

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

 VERSION:     $Id: compute.m,v 1.3 2008/03/06 06:04:56 hewitson Exp $

 HISTORY: 12-03-07 M Hewitson
             Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = compute(varargin)
0002 
0003 
0004 % COMPUTE performs the given operations on the input AOs.
0005 %
0006 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0007 %
0008 % DESCRIPTION: COMPUTE performs the given operations on the input AOs.
0009 %
0010 % CALL:        b = compute(a)
0011 %              b = compute(a, pl)
0012 %              b = compute(a, 'a(1) + a(2)./a(3)')
0013 %              b = compute(a, {'a(1) + a(2)./a(3)', 'log10(a(1))'})
0014 %
0015 % PARAMETERS:  'Operations' - a string array describing the operations to
0016 %                             be performed. The input AOs are collected
0017 %                             together into a vector called 'a' and as
0018 %                             such should be so represented in your
0019 %                             operation description.
0020 %
0021 % If no operation is input, then the output is just a copy of the inputs.
0022 %
0023 % EXAMPLES:
0024 %
0025 % 1)  Add the two AOs, x and y, together
0026 %
0027 %    >> b = compute(x,y, plist('Operations', 'a(1) + a(2)'))
0028 % or
0029 %    >> b = compute(x,y, 'a(1) + a(2)')
0030 %
0031 % 2) Perform two operations such that the output, b, contains two AOs
0032 %
0033 %    >> b = compute([x y], z, plist('Operations', {'2.*a(3)./a(1)', 'a(2)-a(1)'}))
0034 %
0035 % The following call returns a parameter list object that contains the
0036 % default parameter values:
0037 %
0038 % >> pl = compute(ao, 'Params')
0039 %
0040 % The following call returns a string that contains the routine CVS version:
0041 %
0042 % >> version = compute(ao,'Version')
0043 %
0044 % The following call returns a string that contains the routine category:
0045 %
0046 % >> category = compute(ao,'Category')
0047 %
0048 % VERSION:     $Id: compute.m,v 1.3 2008/03/06 06:04:56 hewitson Exp $
0049 %
0050 % HISTORY: 12-03-07 M Hewitson
0051 %             Creation
0052 %
0053 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0054 
0055 ALGONAME = mfilename;
0056 VERSION  = '$Id: compute.m,v 1.3 2008/03/06 06:04:56 hewitson Exp $';
0057 CATEGORY = 'Signal Processing';
0058 bs       = [];
0059 
0060 % Check if this is a call for parameters
0061 if nargin == 2
0062   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0063     in = char(varargin{2});
0064     if strcmp(in, 'Params')
0065       varargout{1} = getDefaultPlist();
0066       return
0067     elseif strcmp(in, 'Version')
0068       varargout{1} = VERSION;
0069       return
0070     elseif strcmp(in, 'Category')
0071       varargout{1} = CATEGORY;
0072       return
0073     end
0074   end
0075 end
0076 
0077 % Collect input ao's, plist's and ao variable names
0078 in_names = {};
0079 for ii = 1:nargin
0080   in_names{end+1} = inputname(ii);
0081 end
0082 [a, pl, invars] = collect_inputs(varargin, in_names);
0083 
0084 % Combine default plist
0085 pl = combine(pl, getDefaultPlist);
0086 
0087 % Look for plist of input char
0088 ops = '';
0089 if ischar(varargin{end})
0090   ops = varargin{end};
0091 else
0092   ops = find(pl, 'Operations');
0093 end
0094 
0095 % Check we have a cell array
0096 if ischar(ops)
0097   ops = {ops};
0098 end
0099 
0100 % Loop over operations
0101 bs = [];
0102 for jj=1:length(ops)
0103   % evaluate this operation
0104   bs = [bs eval(ops{jj})];
0105 end
0106 
0107 % Set outputs
0108 varargout{1} = bs;
0109 
0110 
0111 
0112 %--------------------------------------------------------------------------
0113 % Default parameter list
0114 function pl = getDefaultPlist()
0115 
0116 pl = plist('Operations', 'a');
0117 
0118 
0119

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003