diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@ao/fromSModel.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,69 @@
+% FROMSMODEL Construct a AO from an smodel.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% FUNCTION:    FROMSMODEL Construct a AO from an smodel
+%
+% DESCRIPTION: FROMSMODEL Construct a AO from an smodel
+%
+% CALL:        a = fromSModel(a, pl)
+%
+% PARAMETER:   pl: plist containing 'model'
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function a = fromSModel(a, pli, callerIsMethod)
+  
+  VERSION = '$Id: fromSModel.m,v 1.9 2011/08/15 06:13:07 hewitson Exp $';
+  
+  if callerIsMethod
+    % do nothing
+  else
+    % get AO info
+    ii = ao.getInfo('ao', 'From Smodel');
+    
+    % Set the method version string in the minfo object
+    ii.setMversion([VERSION '-->' ii.mversion]);
+  end
+  
+  if callerIsMethod
+    pl = pli;
+  else
+    % Combine input plist with default values
+    pl = applyDefaults(ii.plists, pli);
+  end
+  
+  pl.getSetRandState();
+  
+  mdl = find(pl, 'model');
+  
+  % Build the plist needed for the smodel/eval call 
+  pl_eval = plist(...
+    'output x', find(pl, 'x'), ...
+    'output xunits', find(pl, 'xunits'), ...
+    'output type', find(pl, 'type'), ...
+    't0', 0 ... 
+    );
+  
+  % Build the object by calling smodel/eval
+  a = mdl.eval(pl_eval);
+  
+  if isempty(pl.find('name'))
+    pl.pset('name', sprintf('eval(%s)', mdl.name));
+  end
+  if isempty(pl.find('description'))
+    pl.pset('description', mdl.description);
+  end
+  
+  if callerIsMethod
+    % do nothing
+  else
+    % Add history
+    a.addHistory(ii, pl, [], mdl.hist);
+  end
+  
+  % Set object properties from the plist
+  a.setObjectProperties(pl);
+  
+end
+
+