Mercurial > hg > ltpda
comparison m-toolbox/m/etc/user_fcn_template.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % FOO description for function 'foo' in one line. Necessary for lookfor functionality. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: FOO detailed description for the function 'foo' | |
5 % | |
6 % CALL: foo(a) | |
7 % [a, b] = foo(a,pl) | |
8 % | |
9 % INPUTS: a - analysis object(s) | |
10 % pl - parameter list(s) | |
11 % | |
12 % OUTPUTS: a - ??? | |
13 % b - ??? | |
14 % | |
15 % PARAMETERS: (Add these parameters to the default parameter list) | |
16 % KEY1: - parameter description | |
17 % KEY2: - parameter description | |
18 % | |
19 % VERSION: $Id: user_fcn_template.m,v 1.1 2010/07/27 13:30:37 ingo Exp $ | |
20 % | |
21 % SEE ALSO: ao/cos, ao/tan, ao/asin, acos, atan | |
22 % | |
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
24 | |
25 %%% REMARK: This is a function template for function which are not part of | |
26 %%% the LTPDA toolbox !!!!!!! | |
27 | |
28 function varargout = foo(varargin) | |
29 | |
30 import utils.const.* | |
31 utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename); | |
32 | |
33 %%% Define version string | |
34 VERSION = '$Id: user_fcn_template.m,v 1.1 2010/07/27 13:30:37 ingo Exp $'; | |
35 | |
36 %%% Collect input variable names | |
37 in_names = cell(size(varargin)); | |
38 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
39 | |
40 %%% Collect all AOs | |
41 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); | |
42 pli = utils.helper.collect_objects(varargin(:), 'plist', in_names); | |
43 | |
44 %%% Decide on a deep copy or a modify | |
45 %%% REMARK: If you create a new AO (call the constructor) then | |
46 %%% it is not necessay to copy the input-AOs !!! | |
47 bs = copy(as, nargout); | |
48 | |
49 %%% Combine with the default plist. This works as first come, first served. | |
50 %%% (It's also necessary to copy the input plist in case we change it later | |
51 %%% in this script - combine does that for you.) | |
52 pl = combine(pli, getDefaultPlist); | |
53 | |
54 %%% go through the inputs | |
55 for kk = 1:numel(bs) | |
56 | |
57 %%% store the input history | |
58 inhists = bs(kk).hist; | |
59 | |
60 %%%%%%%%%% get x- and y-data %%%%%%%%%% | |
61 %%%% REMARK: If you get the data in this way then are x and y always | |
62 %%%% column vectors. | |
63 x = bs(kk).x; | |
64 y = bs(kk).y; | |
65 dx = bs(kk).dx; | |
66 dy = bs(kk).dy; | |
67 | |
68 %%%%%%%%%% some calculations %%%%%%%%%% | |
69 bs(kk).setX(some_new_X_data); | |
70 bs(kk).setY(some_new_Y_data); | |
71 bs(kk).setFs(new_fs); | |
72 bs(kk).setXunits(new_xunits); | |
73 bs(kk).setYunits(new_yunits); | |
74 | |
75 %%% Set Name | |
76 bs(kk).setName('new name'); | |
77 | |
78 %%%%%%%%%% Add history 'step' %%%%%%%%%% | |
79 %%% REMARK: This command is a different to the addHistory because | |
80 %%% 'addHistory' is a protected toolbox method and | |
81 %%% addHistoryStep a public method. The difference is that | |
82 %%% only the user with this method can rebuild the object. | |
83 bs(kk) = addHistoryStep(bs(kk), getInfo('Default'), pl, VERSION, in_names(kk), inhists); | |
84 end | |
85 | |
86 %%% Prepare the output | |
87 if nargout == numel(bs) | |
88 % List of outputs | |
89 for ii = 1:numel(bs) | |
90 varargout{ii} = bs(ii); | |
91 end | |
92 else | |
93 % Single output | |
94 varargout{1} = bs; | |
95 end | |
96 | |
97 end | |
98 | |
99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
100 % Local Functions % | |
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
102 | |
103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
104 % | |
105 % FUNCTION: getInfo | |
106 % | |
107 % DESCRIPTION: Get Info Object | |
108 % | |
109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
110 | |
111 function ii = getInfo(varargin) | |
112 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
113 sets = {}; | |
114 pl = []; | |
115 else | |
116 sets = {'Default'}; | |
117 pl = getDefaultPlist; | |
118 end | |
119 % Build info object | |
120 ii = minfo(mfilename, 'CLASS', '', utils.const.categories.CHOOSE_ME, '$Id: user_fcn_template.m,v 1.1 2010/07/27 13:30:37 ingo Exp $', sets, pl); | |
121 end | |
122 | |
123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
124 % | |
125 % FUNCTION: getDefaultPlist | |
126 % | |
127 % DESCRIPTION: Get Default Plist | |
128 % | |
129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
130 | |
131 function plo = getDefaultPlist() | |
132 | |
133 plo = plist('key1', 1, 'key2', 2); | |
134 | |
135 end | |
136 |