view m-toolbox/classes/@ao/fromPest.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 source

% FROMPEST Construct a AO from a pest.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FUNCTION:    FROMPEST Construct a AO from a pest
%
% DESCRIPTION: FROMPEST Construct a AO from a pest
%
% CALL:        a = fromPest(a, pl)
%
% PARAMETER:   pl: plist containing 'pest'
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function a = fromPest(a, pli)
  
  VERSION = '$Id: fromPest.m,v 1.5 2011/08/15 05:05:48 hewitson Exp $';
  
  % get AO info
  ii = ao.getInfo('ao', 'From Pest');
  
  % Set the method version string in the minfo object
  ii.setMversion([VERSION '-->' ii.mversion]);
  
  % Add default values
  pl = applyDefaults(ii.plists, pli);
  pl.getSetRandState();
  
  ps = find(pl, 'pest');
  param_name = find(pl, 'parameter');
  
  if isempty(param_name)
    names = ps.names;
  elseif isa(param_name, 'char')
    names = {param_name};
  else
    names = param_name;
  end
  a = ao.initObjectWithSize(1, numel(names));
  
  for jj = 1:numel(names)
    a(jj) = ps.find(names{jj});
  end
  
  if isempty(pl.find('name'))
    pl.pset('name', names);
  end
  if isempty(pl.find('description'))
    pl.pset('description', ps.description);
  end
  
  % Add history
  a.addHistory(ii, pl, [], ps.hist);
  
  % Set object properties from the plist
  a.setObjectProperties(pl_set);
  
end