% FROMMODEL Construct an a built in model
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FUNCTION:    fromModel
%
% DESCRIPTION: Construct an ltpda uder objects with history from a
%              built-in model
%
% CALL:        a = fromModel(a, pl)
%
% PARAMETER:   pl: Parameter list object
%
% VERSION:     $Id: fromModel.m,v 1.13 2011/08/15 12:59:04 hewitson Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function obj = fromModel(obj, pl)

  [obj, ii, fcnname] = fromModel@ltpda_uo(obj, pl);
  % Add history
  try 
    feval(fcnname, 'info');
  catch
    % if the model doesn't respond to an 'info' call, then it is an old
    % style model and we need to add history.
    obj.addHistory(ii, pl, [], []);
  end
  
  % Set object properties
  obj.setObjectProperties(pl);
  
end

