www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@conellipsoid/setDistanceMatrix.m
function con = setDistanceMatrix(con, W) %SETDISTANCEMATRIX Get the distance matrix of an ellipsoid constraint % % CON = SETDISTANCEMATRIX(CON, W) % % The distance matrix is the matrix that, along with the center, defines % the ellipsoid constraint. % % The distance matrix, W, must be a positive semi-definite and have the % same number of rows and columns as the constraint has active factors. % % The distance matrix, W, is so-called because it used to generate the % "distance" that a given point, x, is from the surface of the ellipsoid, % specifically, % distance( x ) = (x-xc)' * W * (x-xc) - 1 . % % See also CONELLIPSOID, % CONELLIPSOID/SETCENTER, % CONELLIPSOID/GETDISTANCEMATRIX, % CONELLIPSOID/CONSTRAINTDISTANCE. % Copyright 2005-2008 The MathWorks, Inc. and Ford Global Technologies, Inc. if any( size( W ) ~= nActiveFactors( con ) ), error(message('mbc:conellipsoid:InvalidArgument1')); end lambda = eig( W ); if ~isreal( lambda ) || min( lambda ) < 0 ... || norm( W - W' ) > 1e-8 * max( lambda ), error(message('mbc:conellipsoid:InvalidArgument2')); end con.W = W; %------------------------------------------------------------------------------| % EOF %------------------------------------------------------------------------------|