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

    function mdev = RedoSelect(mdev,bm)
%REDOSELECT redo selection of best model
%
% mdev = RedoSelect(mdev,bm)
 
%  Copyright 2000-2007 The MathWorks, Inc. and Ford Global Technologies, Inc.

% find list of pointers in postorder
pall = postorder(mdevtestplan(mdev),@address);
pall = [pall{:}];
ind = find(pall==address(mdev));

% index to best model
ind = bm{ind};
if ind~=0 && numChildren(mdev)>0
    % remake twostage model
    if ind<=size(mdev.ResponseFeatures,1)
        selrf= mdev.ResponseFeatures(ind,:);
    else
        f=  find(mdev.FitOK,1,'first');
        if ~isempty(f)
            % use fitted coefficients if possible to account for proper delG
            L= LocalModel(mdev,f(1));
            selrf=SelectRF(L);
        else
            selrf= [];
        end
    end
    if size(selrf,1)==1
        if mdev.IsLinearised
            mdev= mle_best(mdev,1);
        else
            [OK,mdev] = MakeTwoStage(mdev,false);
        end
    end
end