view m-toolbox/classes/@ao/fromVals.m @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +0100
parents f0afece42f48
children
line wrap: on
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