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

    function con = setActiveIndices(con, newAi)
%SETACTIVEINDICES Set the indices of the active factors for a Linear Constraint
%
%  CON = SETACTIVEINDICES(CON, AI)
%
%  If an index in AI is already an index in the list of active indices then
%  the coefficient for that factor will be preserved. New active factors
%  will have their coefficient set to zero.
%
%  See also CONLINEAR, CONBASE/SETACTIVEINDICES, CONBASE/GETACTIVEINDICES.

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

newAi = sort( newAi(:).' );
oldAi = getActiveIndices( con ); 

% Set the active indices in the parent object
con.conbase = setActiveIndices( con.conbase, newAi );

% For any new active indices, we set the vector 'A' to zero. For any
% old indices that are kept, we keep the old value.
newA = ones( size( newAi ) );
[tf, loc] = ismember( newAi, oldAi );
newA(tf) = con.A(loc(tf));
con.A = newA;

con = pUpdateScaleFactor( con );

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