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.7 2008/01/15 06:24:51 mauro Exp $

 HISTORY:     dd-mm-yyyy M Hewitson
                 Creation

 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:

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

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

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.7 2008/01/15 06:24:51 mauro 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(ao,'Params')
0030 %
0031 % The following call returns a string that contains the routine CVS version:
0032 %
0033 % >> pl = foo(ao,'Version')
0034 %
0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0036 
0037 ALGONAME = mfilename;
0038 VERSION  = '$Id: ao_fcn_template.m,v 1.7 2008/01/15 06:24:51 mauro Exp $';
0039 bs       = [];
0040 
0041 %% Check if this is a call for parameters or the cvs version string
0042 if nargin == 2
0043   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0044     in = char(varargin{2});
0045     if strcmpi(in, 'Params')
0046       varargout{1} = getDefaultPL();
0047       return
0048     elseif strcmpi(in, 'Version')
0049       varargout{1} = VERSION;
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 % produce one parameter list
0064 if isa(pl, 'plist')
0065   pl = combine(pl, getDefaultPL());
0066 else
0067   pl = getDefaultPL();
0068 end
0069 
0070 %% Get parameters
0071 N = find(pl, 'N');
0072 X = find(pl, 'X');
0073 
0074 %% go through analysis objects
0075 for j=1:numel(as)
0076   a = as(j);
0077 
0078   % get data
0079   [x,y] = get_xy_values(a.data);
0080 
0081   % Do some analysis
0082   y = y;
0083   x = 1:length(y);
0084 
0085   %%-------- Build output AOs
0086 
0087   % make a new xydata object, for example
0088   xy = xydata(x, y);
0089   xy = set(xy, 'name', sprintf('foo(%s)', a.data.name));
0090   xy = set(xy, 'xunits', a.data.yunits);
0091   xy = set(xy, 'yunits', 'Blah');
0092 
0093   % make a new history object
0094   h = history(ALGONAME, VERSION, pl, a.hist);
0095   h = set(h, 'invars', invars);
0096 
0097   % make output analysis object
0098   b = ao(xy, h);
0099 
0100   % name for this object
0101   b  = setnh(b, 'name', sprintf('foo(%s)', invars{j}));
0102   bs = [bs b];
0103 
0104 end
0105 
0106 %% Reshape the ouput to the same size of the input
0107 varargout{1} = reshape(bs, size(as));
0108 
0109 %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0110 %
0111 % FUNCTION:    getDefaultPL
0112 %
0113 % DESCRIPTION: Get default params
0114 %
0115 % HISTORY:     dd-mm-yyyy M Hewitson
0116 %                 Creation
0117 %
0118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0119 function plo = getDefaultPL()
0120 
0121 plo = plist('N', 10, ...
0122             'X', []);
0123 
0124 
0125 % END

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003