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

    function [TP, lChanged, NameMap] = pUpdateToValidNames(TP,NameMap)
%PUPDATETOVALIDNAMES
% 
%  TP = PUPDATETOVALIDNAMES(TP,NameMap)

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

% update input + response variables
[Xp,Yp] = dataptr(TP);
if Yp==0
    lChanged= false;
    return
end

[Yp.info, lChanged] = pUpdateToValidNames(Yp.info, NameMap);

if lChanged
    % only need to update the rest of the tree if something has changed
    
    % update input variables - These sweepset should be drawn from the root sweepsets ONLY
    [X,ChgInps] = pveceval(Xp,@pUpdateToValidNames,NameMap);
    ChgInpts = [ChgInps{:}];
    if any(ChgInpts)
        passign(Xp,X);
        % have to change all responses
        ChangedNames = true(1, numChildren(TP));
    else
        
        % only change names of responses 
        RespModels= children(TP,'model');
        ChangedNames= false(size(RespModels));
        for i = 1:length(RespModels);
            [dum, ChgMdlNames] = pUpdateToValidNames(varname(RespModels{i}), NameMap);
            if ChgMdlNames
                ChangedNames(i) = true;
            end
        end
        
    end

    % update model names
    for i = 1:numstages(TP)
        D = TP.DesignDev(i);
        m = pUpdateToValidNames(getModel(D), NameMap);
        TP.DesignDev(i) = setmodel(D, m);
    end
    

    if numstages(TP)>1
        % update all response nodes
        children(TP,ChangedNames,@pUpdateToValidNames,NameMap);
        
        % pointers to all local nodes
        pLocal = children(TP,ChangedNames,@children);
        % local nodes have to be handled differently because of response feature
        % dats
        if ~isempty(pLocal)
            pveceval([pLocal{:}],@pUpdateToValidNames,NameMap);
        end
    else
        % update one-stage model nodes
        children(TP,ChangedNames,@preorder,@pUpdateToValidNames,NameMap);
    end
end

% Monitor Plots
if ~isempty(TP.Monitor)
    if ~isempty(TP.Monitor.values)
        TP.Monitor.values = pUpdateToValidNames(TP.Monitor.values, NameMap);
    end
    if ~isempty(TP.Monitor.Xdata)
        TP.Monitor.Xdata = pUpdateToValidNames(TP.Monitor.Xdata, NameMap);
    end
end

xregpointer(TP);