www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdev_local/checkmodel.m

    function OK= checkmodel(mdev)
%CHECKMODEL check the integrity of the model objects at load time 

% *** Sh	adowed from core to allow for linearised two-stage models *** %

%  Copyright 2005-2015 The MathWorks, Inc. and Ford Global Technologies, Inc.
%   $Revision: 498 $  $Date: 2007-10-04 12:24:55 +0100 (Thu, 04 Oct 2007) $

L= model(mdev);
% This section removed for Ford extras
% modes= mle_modes(mdev);
% if mdev.IsLinearised || (length(modes)>2 && modes(3)==3)
%     error('mbc:mdev_local:LoadError','Linearised two-stage models not supported')
% end

if isa(L,'localmod')
    OK= checkmodel(L);
    yi= yinfo(L);
    if strcmp(yi.Name,'y');
        % update all the model info
        mdev= modelinfo(mdev);
    end
    
    if ~isPointByPoint(mdev) && isa(L,'localmulti') 
        [L,mdev.AllModels] = pUpdateR2(L,mdev.AllModels);
        mdev = model(mdev,L);
        
        % update to point-by-point node
        mdev = guid(mdev,'ptbypt');
        mdev = status(mdev,1,0);
        % pooled statistics only include local and validation RMSE
        stats = statistics(mdev);
        mdev = statistics(mdev,[stats(1) NaN]);
        
        pResp = Parent(mdev);
        mdev = name(mdev,pResp.name);
        T = mdevtestplan(mdev);
        D = designdev(T);
        mdl = HSModel(D);
        if ~isa(get(mdl,'Local'),'localmulti')
            % update testplan local model to a localmulti
            mdl = set(mdl,'Local',L);
            D = HSModel(D,mdl);
            T = designdev(T,D);
        end
        
        % attach local node to test plan and delete old response
        ind = pResp.childindex;
        ch = children(T);
        ch(ind) = address(mdev);
        T = AddChild(T,mdev);
        AssignChildren(T,ch);
        % delete response node (need to dereference children first
        pResp.AssignChildren([]);
        pResp.delete;
    end
else
   error('mbc:mdev_local:LoadError','%s''s model is corrupt ',fullname(mdev))
end