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

    function con = removeInputIndices(con, remInd)
%REMOVEINPUTINDICES Remove input factors from a constraint
%
%  CON = REMOVEINPUTINDICES(CON, IDX) removes the specified input factors
%  from the constraint.
%
%  See also CONBASE, CONBASE/SETACTIVEINDICES.

%  Copyright 2005 The MathWorks, Inc.

nF = nFactors(con);
keepInd = setdiff(1:nF, remInd);
activeLims = nActiveFactorsAllowed(con);
activeInd = getActiveIndices(con);

newCIF = con.InputFactors(keepInd);

if length(newCIF)<activeLims(1)
    error(message('mbc:conbase:InvalidState4', activeLims( 1 )));
end

% First change the existing active indices so that none of the factors to
% be removed are active
keepActiveInd = ~ismember(activeInd, remInd);
if sum(keepActiveInd)<activeLims(1)
    error(message('mbc:conbase:InvalidState5', activeLims( 1 )));
end

% There are enough remaining active indices
con = setActiveIndices(con, activeInd(keepActiveInd));

% Now remove the actual input factors
con.InputFactors = newCIF;

% Adjust active factor indices to account for the missing factors
AF = con.ActiveFactors;
for n = 1:length(AF)
    AF(n) = AF(n) - sum(AF(n)>remInd);
end
con.ActiveFactors = AF;


%------------------------------------------------------------------------------|
% EOF
%------------------------------------------------------------------------------|