comparison m-toolbox/classes/@ao/fromFcn.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 % FROMFCN Construct an ao from a function string
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % FUNCTION: fromFcn
5 %
6 % DESCRIPTION: Construct an ao from a function string
7 %
8 % CALL: a = fromFcn(a, pl)
9 %
10 % PARAMETER: pl: Parameter list object
11 %
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 function a = fromFcn(a, pli)
14
15 VERSION = '$Id: fromFcn.m,v 1.22 2011/08/17 07:01:45 hewitson Exp $';
16 % get AO info
17 ii = ao.getInfo('ao', 'From Function');
18
19 % Set the method version string in the minfo object
20 ii.setMversion([VERSION '-->' ii.mversion]);
21
22 % Add default values
23 pl = applyDefaults(ii.plists, pli);
24 % Tell parse that the output value for fcn should be a double so that it evals the user input
25 pl = parse(pl, plist('fcn', []));
26 % Set random state in case we are rebuilding and the function used rand etc
27 pl.getSetRandState();
28
29 fcn = find(pl, 'fcn');
30
31 % Set data of analysis object
32 if ischar(fcn)
33 a.data = cdata(eval(fcn));
34 elseif isnumeric(fcn)
35 a.data = cdata(fcn);
36 else
37 error('### unknown format for the function');
38 end
39
40 % Set non-object properties
41 a.setYunits(pl.find('yunits'));
42
43 % Add history
44 a.addHistory(ii, pl, [], []);
45
46 % Set object properties
47 a.setObjectProperties(pl);
48
49 end
50