


LOADMODEL - load a model using built-in load module
check that model prototype has not changed. if so, adapt to new model prototype.
Usage:
loadmodel(varargin)

0001 function loadmodel(varargin) 0002 %LOADMODEL - load a model using built-in load module 0003 % 0004 % check that model prototype has not changed. if so, adapt to new model prototype. 0005 % 0006 % Usage: 0007 % loadmodel(varargin) 0008 0009 path=varargin{1}; 0010 try, 0011 s=load(path,'-mat'); 0012 %get name of model variable 0013 fieldname=char(fieldnames(s)); 0014 md=eval(['s.' fieldname]); 0015 if ~strcmpi(class(md),'model'), 0016 md2=model; 0017 md2=structtomodel(md2,md); 0018 md=md2; 0019 clear md2; 0020 end 0021 assignin('caller',fieldname,md); 0022 catch 0023 error(['could not load model' path]); 0024 end