www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregtransient/funcinit.m
function U = funcinit(U,fname,doQuick) %FUNCINIT Initialise user defined model defined by 'fname.m' % % M = FUNCINIT(M, FNAME) initialises the transient model for the function % 'FNAME.m'. % Copyright 2000-2014 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin<3 doQuick = false; end % Check fname exists U = ErrorStatus(U,true); U.simName = fname; U = rename(U,fname); U = update(U,[]); U = update(U,initial(U)); U = simvars(U); [~,U] = state0(U); U = ErrorStatus(U,false); if ~strcmp(fname,'functemplate') checkmodel(U); end if ~doQuick [LB,~]= range(U); LB= LB(:)'; EvalModel(U,[0 LB(2:end)]); iCloseSL(U); end function iCloseSL(U) try model = U.simName; mh = get_param(model, 'handle'); bh = find_system(model,'LookUnderMasks','on', 'FindAll', 'on','blocktype','SubSystem'); allH = [mh; bh]; if ~any(strcmp('on', get_param(allH, 'open'))), % close system if it is not visible close_system(U.simName,0); end end