comparison m-toolbox/classes/@ao/fromSModel.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 % FROMSMODEL Construct a AO from an smodel.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % FUNCTION: FROMSMODEL Construct a AO from an smodel
5 %
6 % DESCRIPTION: FROMSMODEL Construct a AO from an smodel
7 %
8 % CALL: a = fromSModel(a, pl)
9 %
10 % PARAMETER: pl: plist containing 'model'
11 %
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13
14 function a = fromSModel(a, pli, callerIsMethod)
15
16 VERSION = '$Id: fromSModel.m,v 1.9 2011/08/15 06:13:07 hewitson Exp $';
17
18 if callerIsMethod
19 % do nothing
20 else
21 % get AO info
22 ii = ao.getInfo('ao', 'From Smodel');
23
24 % Set the method version string in the minfo object
25 ii.setMversion([VERSION '-->' ii.mversion]);
26 end
27
28 if callerIsMethod
29 pl = pli;
30 else
31 % Combine input plist with default values
32 pl = applyDefaults(ii.plists, pli);
33 end
34
35 pl.getSetRandState();
36
37 mdl = find(pl, 'model');
38
39 % Build the plist needed for the smodel/eval call
40 pl_eval = plist(...
41 'output x', find(pl, 'x'), ...
42 'output xunits', find(pl, 'xunits'), ...
43 'output type', find(pl, 'type'), ...
44 't0', 0 ...
45 );
46
47 % Build the object by calling smodel/eval
48 a = mdl.eval(pl_eval);
49
50 if isempty(pl.find('name'))
51 pl.pset('name', sprintf('eval(%s)', mdl.name));
52 end
53 if isempty(pl.find('description'))
54 pl.pset('description', mdl.description);
55 end
56
57 if callerIsMethod
58 % do nothing
59 else
60 % Add history
61 a.addHistory(ii, pl, [], mdl.hist);
62 end
63
64 % Set object properties from the plist
65 a.setObjectProperties(pl);
66
67 end
68
69