www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@modeldev/status.m
function s=status(mdev,s,Climb) %STATUS get or set status for modeldev node % s=status(mdev,s) % s=status(mdev,s,Climb) % A status of 2 sets the node as best. When Climb is true (the default), % the status of parent nodes is also updated. If the current node is set % as best then the parent node is updated. If a node is the only child % then its this change is propagated up the tree. % Warning: The flow for the recursion is complex and involves interaction with % BestModel. Climb is false is used to prevent recursion. % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin>1 % set the status if nargin<3 Climb=1; end s = double(s); pCurrent= address(mdev); p= Parent(mdev); if p~=0 && Climb~=0 mdevParent=info(p); hb= hasBest(mdev); if hb && numChildren(mdevParent)==1 && s==1 && ... (~isa(mdevParent,'mdevtestplan')) && ~isa(mdevParent,'mdev_local') % has best model + only one child + set status to 1 % copy up tree and make best model mdev.Status=s; pointer(mdev); mdevParent=BestModel(mdevParent,pCurrent,pCurrent); % change status to 2 mdev=info(mdev); mdev.Status=2; pointer(mdev); % recurse up tree status(mdevParent,s); elseif isbest(mdev) && s~=2 % mdev.Status=s; pointer(mdev); % unassign best model for parent mdevParent= BestModel(mdevParent,xregpointer,pCurrent); % recurse up tree status(mdevParent,s); else mdev.Status=s; pointer(mdev); end else mdev.Status=s; pointer(mdev); end % make sure you return the dynamic copy of the mdev object mdev=info(mdev); if isBrowserProject(mdev) mbH= MBrowser; % this updates the icon on the modelbrowser tree. try mbH.doDrawTree(address(mdev)); end end s= mdev; else % output the status s= mdev.Status; end