view m-toolbox/classes/@ltpda_uoh/fromModel.m @ 44:409a22968d5e default

Add unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 18:42:11 +0100
parents bc767aaa99a8
children
line wrap: on
line source

% 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.14 2011/12/02 09:05:15 hewitson Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function obj = fromModel(obj, pl)

  [obj, ii, fcnname, pl] = 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
  
  % Here we make a check on the default plist keys because these properties
  % may have been set in the model. We make the assumption that if they are
  % empty, the user had no intention of setting them so we can remove them
  % and keep the value set in the model.
  if isempty(pl.find('name'))
    pl.remove('name');
  end
  if isempty(pl.find('description'))
    pl.remove('description');
  end
  if isempty(pl.find('plotinfo'))
    pl.remove('plotinfo');
  end
  
  % Set object properties
  obj.setObjectProperties(pl);
  
end