view m-toolbox/classes/@ao/fromFcn.m @ 51:9d5c88356247 database-connection-manager

Make unit tests database connection parameters configurable
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:24:37 +0100
parents f0afece42f48
children
line wrap: on
line source

% FROMFCN Construct an ao from a function string
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FUNCTION:    fromFcn
%
% DESCRIPTION: Construct an ao from a function string
%
% CALL:        a = fromFcn(a, pl)
%
% PARAMETER:   pl: Parameter list object
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function a = fromFcn(a, pli)
  
  VERSION = '$Id: fromFcn.m,v 1.22 2011/08/17 07:01:45 hewitson Exp $';
  % get AO info
  ii = ao.getInfo('ao', 'From Function');
  
  % Set the method version string in the minfo object
  ii.setMversion([VERSION '-->' ii.mversion]);
  
  % Add default values
  pl = applyDefaults(ii.plists, pli);
  % Tell parse that the output value for fcn should be a double so that it evals the user input
  pl = parse(pl, plist('fcn', []));
  % Set random state in case we are rebuilding and the function used rand etc
  pl.getSetRandState();
  
  fcn = find(pl, 'fcn');
  
  % Set data of analysis object
  if ischar(fcn)
    a.data  = cdata(eval(fcn));
  elseif isnumeric(fcn)
    a.data = cdata(fcn);
  else
    error('### unknown format for the function');
  end
  
  % Set non-object properties
  a.setYunits(pl.find('yunits'));
  
  % Add history
  a.addHistory(ii, pl, [], []);
  
  % Set object properties
  a.setObjectProperties(pl);
  
end