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

    function con = resetFromInputs(con, ResetInd)
%RESETFROMINPUTS Reset constraint parameters after input changes
%
%  CON = RESETFROMINPUTS(CON) resets all of the constraint parameters that
%  depend on input factor settings to their default values.
%
%  CON = RESETFROMINPUTS(CON, IND) assumes that the input factors indicated
%  by the indices in IND have changed and resets only the parameters that
%  depended on the settings for those inputs.

%  Copyright 2005 The MathWorks, Inc. and Ford Global Technologies, Inc.



if nargin<2
    ResetInd = getActiveIndices(con);
else
    % Remove non-active indices as these cannot affect the settings
    ResetInd = intersect(ResetInd, getActiveIndices(con));
end

if ~isempty(ResetInd)
    ActiveInd = getActiveIndices(con);
    xc = zeros(1, nFactors(con));
    xc(ActiveInd) = getCenter(con);
    
    cif = getInputFactors(con);
    xc(ResetInd) = 0.5 * (cif(ResetInd).Min + cif(ResetInd).Max);
    
    con = setCenter(con, xc(ActiveInd));
end