Mercurial > hg > ltpda
diff m-toolbox/classes/@ao/fromVals.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/fromVals.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,66 @@ +% 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 +