www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@designdev/UpdateModels.m

    function DDev = UpdateModels(DDev,m,Stage)
%UPDATEMODELS Update all models in the designdev
%
%  DD = UPDATEMODELS(DD, M, STAGE) updates the specified stage in the
%  designdev  DD with information from the model M.  All models in designs
%  in the designdev have their input information updated to match that of
%  M.

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


NF = nfactors(DDev);
Dcell = DesignDev2Cell(DDev);
if nargin==3
    d = Dcell(Stage);
    NF = NF(Stage);
else
    d = Dcell;
    Stage = ':';
end

if sum(NF)~= nfactors(m)
    if length(d)==1
        des = designobj(m);
        d{1}.DesignTree.designs = {des};
        d{1}.DesignTree.parents = 0;
        d{1}.DesignTree.chosen = 1;
    else
        error(message('mbc:designdev:InvalidArgument'))
    end
else
    Inputs = getInputs(m);
    j=1;
    for i=1:length(d)
        Mi= getModel(d{i});
        nf= nfactors(Mi);

        ind= j:j+nf-1;
        StageInputs = Inputs(ind);

        des= d{i}.DesignTree.designs;
        for k= 1:length(des)
            mdl= model(des{k});
            mdl = setInputs(mdl,StageInputs);
            des{k}= model(des{k},mdl);
        end
        d{i}.DesignTree.designs= des;

        j= j+nf;
    end
end

Dcell(Stage)= d;
DDev = Cell2DesignDev(Dcell);