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

    function OK= deleteOK(mdev)
% MODELDEV/DELETEOK checks whether it is ok to delete this modeldev node
%
% this just checks whether it is a datumlink

%  Copyright 2000-2009 The MathWorks, Inc. and Ford Global Technologies, Inc.



allch= preorder(mdev,@address);
if iscell(allch)
   allch= [allch{:}];
end
[pdatum,presp]= datumlink(mdev);
OK = true;
if ~isnull(pdatum) && any(pdatum==allch)
    % trying to delete datum link
    TS = presp.model;
    if presp.childindex==1 && ismember(get(TS,'DatumType'),1:2)
       % look at datum links for other responses
       TP= presp.Parent;
       pLinks = TP.children(@datumlink);
       % can't delete  response models with datum links
       OK = sum([pLinks{:}]==pdatum)==1;
    end
    if OK && ~any(pdatum.Parent==allch)
        % deleting datum model and not local node
        OK = false;
    end
   
end