Home > m > etc > ao_fcn_template.m

ao_fcn_template

PURPOSE ^

FOO overloads the foo function for Analysis Objects.

SYNOPSIS ^

function varargout = foo(varargin)

DESCRIPTION ^

 FOO overloads the foo function for Analysis Objects.

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

 DESCRIPTION: FOO overloads the foo function for Analysis Objects.

 CALL:                foo(a)
              [a, b] = foo(a,pl)

 INPUTS:      a  - analysis object(s)
              pl - parameter list(s)
                      ...

 OUTPUTS:     a  - ???
              b  - ???

 PARAMETERS:  N: - description (Add this parameters to the default parameter list)
              X: - description

 VERSION:     $Id: ao_fcn_template.m,v 1.3 2007/07/16 12:55:15 ingo Exp $

 HISTORY:     dd-mm-yyyy M Hewitson
                 Creation

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

 >> pl = foo('Params')

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = foo(varargin)
0002 % FOO overloads the foo function for Analysis Objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: FOO overloads the foo function for Analysis Objects.
0007 %
0008 % CALL:                foo(a)
0009 %              [a, b] = foo(a,pl)
0010 %
0011 % INPUTS:      a  - analysis object(s)
0012 %              pl - parameter list(s)
0013 %                      ...
0014 %
0015 % OUTPUTS:     a  - ???
0016 %              b  - ???
0017 %
0018 % PARAMETERS:  N: - description (Add this parameters to the default parameter list)
0019 %              X: - description
0020 %
0021 % VERSION:     $Id: ao_fcn_template.m,v 1.3 2007/07/16 12:55:15 ingo Exp $
0022 %
0023 % HISTORY:     dd-mm-yyyy M Hewitson
0024 %                 Creation
0025 %
0026 % The following call returns a parameter list object that contains the
0027 % default parameter values:
0028 %
0029 % >> pl = foo('Params')
0030 %
0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 
0033 
0034 %---------------- Standard history variable
0035 
0036 ALGONAME = mfilename;
0037 VERSION  = '$Id: ao_fcn_template.m,v 1.3 2007/07/16 12:55:15 ingo Exp $';
0038 
0039 %---------------- Check if this is a call for parameters
0040 if nargin == 1
0041   if ischar(varargin{1})
0042     if strcmp(varargin{1}, 'Params')
0043       varargout{1} = getDefaultPL();
0044       return
0045     end
0046   end
0047 end
0048 
0049 
0050 %---------------- capture input variable names, AOs, and plists
0051 invars = {};
0052 as     = [];
0053 ps     = [];
0054 for j=1:nargin
0055   if isa(varargin{j}, 'ao')
0056     invars = [invars cellstr(inputname(j))];
0057   end
0058   if isa(varargin{j}, 'ao')
0059     as = [as varargin{j}];
0060   end
0061   if isa(varargin{j}, 'plist')
0062     ps = [ps varargin{j}];
0063   end
0064 end
0065 
0066 % produce one plist
0067 if isa(ps, 'plist')
0068   pl = combine(ps, getDefaultPL());
0069 else
0070   pl = getDefaultPL();
0071 end
0072 
0073 % number of input AOs
0074 na = length(as);
0075 
0076 % Get parameters
0077 N = find(pl, 'N');
0078 X = find(pl, 'X');
0079 
0080 %---------------- Loop over input AOs
0081 
0082 % Initialise output
0083 bs = [];
0084 
0085 % start looping
0086 for j=1:na
0087   a = as(j);
0088 
0089   % get data
0090   adata = getAOdata(a);
0091 
0092   % Do some analysis
0093   y = adata;
0094   x = 1:length(y);
0095 
0096   %-------- Build output AOs
0097 
0098   % make a new xydata object, for example
0099   xy = xydata(x, y);
0100   xy = set(xy, 'name', sprintf('foo(%s)', a.data.name));
0101   xy = set(xy, 'xunits', a.data.yunits);
0102   xy = set(xy, 'yunits', 'Blah');
0103 
0104   % make a new history object
0105   h = history(ALGONAME, VERSION, pl, a.hist);
0106   h = set(h, 'invars', invars);
0107 
0108   % make output analysis object
0109   b = ao(xy, h);
0110 
0111   % name for this object
0112   if isempty(invars{j})
0113     n1 = a.name;
0114   else
0115     n1 = invars{j};
0116   end
0117   b  = set(b, 'name', sprintf('foo(%s)', n1));
0118   bs = [bs b];
0119 
0120 end
0121 
0122 %---------------- Set outputs
0123 varargout{1} = bs;
0124 
0125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0126 %
0127 % FUNCTION:    getDefaultPL
0128 %
0129 % DESCRIPTION: Get default params
0130 %
0131 % HISTORY:     dd-mm-yyyy M Hewitson
0132 %                 Creation
0133 %
0134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0135 function plo = getDefaultPL()
0136 
0137 disp('* creating default plist...');
0138 plo = plist();
0139 plo = append(plo, param('N', 10));
0140 plo = append(plo, param('X', []));
0141 disp('* done.');
0142 
0143 
0144 % END

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003