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  - ???

 PARAMETER LIST:  
 <key>                <value>                   <description>
 'A'                    'a'                   parameter description
 'N'                     5                    parameter description
  DESCRIPTION      'User func. template'       routine description  

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

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

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

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

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

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

 VERSION:     $Id: ao_fcn_template.html,v 1.14 2008/03/31 10:27:44 hewitson Exp $

 HISTORY:     dd-mm-yyyy M Hewitson
                 Creation

 SEE ALSO: ao/cos, ao/tan, ao/asin, acos, atan

 SEE: <a href="matlab: help ao/Contents;">HELP: All Analysis Object Functions:</a>
      <a href="matlab: helpwin ao/Contents;">DOC: All Analysis Object Functions:</a>

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

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 % PARAMETER LIST:
0019 % <key>                <value>                   <description>
0020 % 'A'                    'a'                   parameter description
0021 % 'N'                     5                    parameter description
0022 %  DESCRIPTION      'User func. template'       routine description
0023 %
0024 % The following call returns a parameter list object that contains the
0025 % default parameter values:
0026 %
0027 % >> pl = foo(ao, 'Params')
0028 %
0029 % The following call returns a string that contains the routine CVS version:
0030 %
0031 % >> version = foo(ao, 'Version')
0032 %
0033 % The following call returns a string that contains the routine category:
0034 %
0035 % >> category = foo(ao, 'Category')
0036 %
0037 % VERSION:     $Id: ao_fcn_template.html,v 1.14 2008/03/31 10:27:44 hewitson Exp $
0038 %
0039 % HISTORY:     dd-mm-yyyy M Hewitson
0040 %                 Creation
0041 %
0042 % SEE ALSO: ao/cos, ao/tan, ao/asin, acos, atan
0043 %
0044 % SEE: <a href="matlab: help ao/Contents;">HELP: All Analysis Object Functions:</a>
0045 %      <a href="matlab: helpwin ao/Contents;">DOC: All Analysis Object Functions:</a>
0046 %
0047 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0048 
0049 ALGONAME = mfilename;
0050 VERSION  = '$Id: ao_fcn_template.html,v 1.14 2008/03/31 10:27:44 hewitson Exp $';
0051 bs       = [];
0052 
0053 %% Check if this is a call for parameters or the cvs version string
0054 if nargin == 2
0055   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0056     in = char(varargin{2});
0057     if strcmpi(in, 'Params')
0058       varargout{1} = getDefaultPL();
0059       return
0060     elseif strcmpi(in, 'Version')
0061       varargout{1} = VERSION;
0062       return
0063     end
0064   end
0065 end
0066 
0067 %% Collect input ao's, plist's and ao variable names
0068 in_names = {};
0069 for ii = 1:nargin
0070   in_names{end+1} = inputname(ii);
0071 end
0072 
0073 [as, pl, invars] = collect_inputs(varargin, in_names);
0074 
0075 % produce one parameter list
0076 if isa(pl, 'plist')
0077   pl = combine(pl, getDefaultPL());
0078 else
0079   pl = getDefaultPL();
0080 end
0081 
0082 %% Get parameters
0083 N = find(pl, 'N');
0084 X = find(pl, 'X');
0085 
0086 %% go through analysis objects
0087 for j=1:numel(as)
0088   a = as(j);
0089 
0090   % get data
0091   [x,y] = get_xy_values(a.data);
0092 
0093   % Do some analysis
0094   y = y;
0095   x = 1:length(y);
0096 
0097   %%-------- Build output AOs
0098 
0099   % make a new xydata object, for example
0100   xy = xydata(x, y);
0101   xy = set(xy, 'name', sprintf('foo(%s)', a.data.name));
0102   xy = set(xy, 'xunits', a.data.xunits);
0103   xy = set(xy, 'yunits', 'Blah');
0104 
0105   % make a new history object
0106   h = history(ALGONAME, VERSION, pl, a.hist);
0107   h = set(h, 'invars', invars);
0108 
0109   % make output analysis object
0110   b = ao(xy, h);
0111 
0112   % name for this object
0113   b  = setnh(b, 'name', sprintf('foo(%s)', invars{j}));
0114   bs = [bs b];
0115 
0116 end
0117 
0118 %% Reshape the ouput to the same size of the input
0119 varargout{1} = reshape(bs, size(as));
0120 
0121 %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0122 %
0123 % FUNCTION:    getDefaultPL
0124 %
0125 % DESCRIPTION: Get default params
0126 %
0127 % HISTORY:     dd-mm-yyyy M Hewitson
0128 %                 Creation
0129 %
0130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0131 function plo = getDefaultPL()
0132 
0133 plo = plist('N', 10, ...
0134   'X', [], ...
0135   'DESCRIPTION','LTPDA User Function Template');
0136 
0137 
0138 % END

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