www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@conrange/bringInside.m
function X = bringInside(con, X) %BRINGINSIDE Move a set of points so they are all inside the constraint. % % Y = BRINGINSIDE(CON, X) is the data set X but with any points outside the % constraint CON projected into the constraint. % If X(i,:) is inside the constraint, then Y(i,:) = X(i,:). % If X(i,:) is outside the constriant, then Y(:,i) will be the closest point to % X(i,:) that is inside (on the boundary of) the constraint. % % See also CONRANGE, CONBASE/BRINGINSIDE. % Copyright 2000-2005 The MathWorks, Inc. A = -inf( 1, nFactors( con ) ); B = inf( 1, nFactors( con ) ); ai = getActiveIndices( con ); A(ai) = con.Center - con.HalfWidth; B(ai) = con.Center + con.HalfWidth; i = ones( size( X, 1 ), 1 ); X = max( A(i,:), min( X, B(i,:) ) ); %------------------------------------------------------------------------------| % EOF %------------------------------------------------------------------------------|