view m-toolbox/classes/@ao/fromVals.m @ 12:86aabb42dd84
database-connection-manager
Use utils.repository utilities
author
Daniele Nicolodi <nicolodi@science.unitn.it>
date
Mon, 05 Dec 2011 16:20:06 +0100 (2011-12-05)
parents
f0afece42f48
children
line source
+ − % FROMVALS Construct an ao from a value set
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ − %
+ − % FUNCTION: fromVals
+ − %
+ − % DESCRIPTION: Construct an ao from a value set
+ − %
+ − % CALL: a = fromVals(a, pli, callerIsMethod)
+ − %
+ − % PARAMETERS:
+ − % N: Number of copies of the object to produce
+ − % vals: Constant values
+ − %
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ − function a = fromVals(a, pli, callerIsMethod)
+ −
+ − VERSION = '$Id: fromVals.m,v 1.38 2011/08/16 04:57:59 hewitson Exp $';
+ −
+ − if callerIsMethod
+ − % do nothing
+ − else
+ − % get AO info
+ − ii = ao.getInfo('ao', 'From Values');
+ −
+ − % Set the method version string in the minfo object
+ − ii.setMversion([VERSION '-->' ii.mversion]);
+ − end
+ −
+ − % Combine input plist with default values
+ − if callerIsMethod
+ − pl = pli;
+ − N = 1;
+ − else
+ − % Combine input plist with default values
+ − % TODO: the parse step should be removed and included somehow into plist/applyDefaults
+ − pl = applyDefaults(ii.plists, pli);
+ − % Get values from the plist
+ − N = find(pl, 'N');
+ − end
+ −
+ −
+ − vals = find(pl, 'vals');
+ −
+ − % Create an AO with cdata if no value is set
+ − if isempty(vals)
+ − vals = 0;
+ − end
+ −
+ − % Set data
+ − a.data = cdata(repmat(vals, 1, N));
+ −
+ − if callerIsMethod
+ − % do nothing
+ − else
+ − % Add history
+ − a.addHistory(ii, pl, [], []);
+ − end
+ −
+ − % Set yunits
+ − a.setYunits(pl.find('yunits'));
+ −
+ − % Set any remaining object properties which exist in the default plist
+ − a.setObjectProperties(pl);
+ −
+ − end
+ −