Home > m > etc > ltpda_user_fcn_template.m

ltpda_user_fcn_template

PURPOSE ^

LTPDA_FOO is the standard function template for user functions

SYNOPSIS ^

function varargout = ltpda_foo(varargin)

DESCRIPTION ^

 LTPDA_FOO is the standard function template for user functions

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

 DESCRIPTION: LTPDA_FOO is the standard function template for LTPDA user
 functions

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

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

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

 PARAMETERS:  (Add these parameters to the default parameter list)
   A: - parameter description 
   X: - parameter description
   DESCRIPTION: - user defined routine description

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

 HISTORY:     dd-mm-yyyy M Hewitson
                 Creation

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

 >> pl = ltpda_foo('Params')

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

 >> version = ltpda_foo('Version')

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

 >> category = ltpda_foo('Category')

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = ltpda_foo(varargin)
0002 % LTPDA_FOO is the standard function template for user functions
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: LTPDA_FOO is the standard function template for LTPDA user
0007 % functions
0008 %
0009 % CALL:                 ltpda_foo(a)
0010 %              [a, b] = ltpda_foo(a,pl)
0011 %
0012 % INPUTS:      a  - analysis object(s)
0013 %              pl - parameter list(s)
0014 %                      ...
0015 %
0016 % OUTPUTS:     a  - ???
0017 %              b  - ???
0018 %
0019 % PARAMETERS:  (Add these parameters to the default parameter list)
0020 %   A: - parameter description
0021 %   X: - parameter description
0022 %   DESCRIPTION: - user defined routine description
0023 %
0024 % VERSION:     $Id: ltpda_user_fcn_template.html,v 1.7 2008/03/31 10:27:44 hewitson Exp $
0025 %
0026 % HISTORY:     dd-mm-yyyy M Hewitson
0027 %                 Creation
0028 %
0029 % The following call returns a parameter list object that contains the
0030 % default parameter values:
0031 %
0032 % >> pl = ltpda_foo('Params')
0033 %
0034 % The following call returns a string that contains the routine CVS version:
0035 %
0036 % >> version = ltpda_foo('Version')
0037 %
0038 % The following call returns a string that contains the routine category:
0039 %
0040 % >> category = ltpda_foo('Category')
0041 %
0042 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0043 
0044 
0045 
0046 %% ---------------- Standard history variables
0047 
0048 ALGONAME = mfilename;
0049 VERSION  = '$Id: ltpda_user_fcn_template.html,v 1.7 2008/03/31 10:27:44 hewitson Exp $';
0050 CATEGORY = 'Signal Processing';
0051 
0052 
0053 %% Check if this is a call for parameters, the CVS version string
0054 % or the function category
0055 if nargin == 1 && ischar(varargin{1})
0056   in = char(varargin{1});
0057   if strcmp(in, 'Params')
0058     varargout{1} = getDefaultPL();
0059     return
0060   elseif strcmp(in, 'Version')
0061     varargout{1} = VERSION;
0062     return
0063   elseif strcmp(in, 'Category')
0064     varargout{1} = CATEGORY;
0065     return
0066   end
0067 end
0068 
0069 
0070 %% Collect input ao's, plist's and ao variable names
0071 in_names = {};
0072 for ii = 1:nargin
0073   in_names{end+1} = inputname(ii);
0074 end
0075 
0076 [as, pl, invars] = collect_inputs(varargin, in_names);
0077 
0078 % produce one parameter list
0079 if isa(pl, 'plist')
0080   pl = combine(pl, getDefaultPL());
0081 else
0082   pl = getDefaultPL();
0083 end
0084 
0085 
0086 %% Get parameters
0087 A = find(pl, 'A');
0088 X = find(pl, 'X');
0089 
0090 
0091 %% Initialize outputs
0092 bs = [];
0093 
0094 
0095 %% Go through analysis objects
0096 for j=1:numel(as)
0097   a = as(j);
0098 
0099   % get data
0100   [x,y] = get_xy_values(a.data);
0101 
0102   % Do some analysis
0103   y = 2*A * (y + X);
0104   x = 1:length(x);
0105 
0106   %%-------- Build output AOs
0107 
0108   % make a new xydata object, for example
0109   xy = xydata(x, y);
0110   xy = set(xy, 'name', sprintf('ltpda_foo(%s)', a.data.name));
0111   xy = set(xy, 'xunits', a.data.xunits);
0112   xy = set(xy, 'yunits', 'Blah');
0113 
0114   % make a new history object
0115   h = history(ALGONAME, VERSION, pl, a.hist);
0116   h = set(h, 'invars', invars);
0117 
0118   % make output analysis object
0119   b = ao(xy, h);
0120 
0121   % name, mfilename, description for this object
0122   b = setnh(b, 'name', sprintf('ltpda_foo(%s)', invars{j}),...
0123     'description', find(pl,'description'));
0124 
0125   bs = [bs b];
0126 
0127 end
0128 
0129 
0130 %% Reshape the ouput to the same size of the input
0131 varargout{1} = reshape(bs, size(as));
0132 
0133 
0134 %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0135 %
0136 % FUNCTION:    getDefaultPL
0137 %
0138 % DESCRIPTION: Get default params
0139 %
0140 % HISTORY:     dd-mm-yyyy M Hewitson
0141 %                 Creation
0142 %
0143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0144 function plo = getDefaultPL()
0145 
0146 plo = plist('A', 10, ...
0147   'X', [1], ...
0148   'DESCRIPTION','LTPDA User Function Template');
0149 
0150 
0151 % END

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