www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@conellipsoid/findBoundaryPoints.m
function [con, bp, ok] = findBoundaryPoints(con, opts, X) %FINDBOUNDARYPOINTS Find boundary points for an ellipsoid constraint % % [CON, BP] = FINDBOUNDARYPOINTS(CON, OPTS, X) % % See also CONELLIPSOID, CONELLIPSOID/GETBOUNDARYPOINTOPTIONS, % CONBASE/FINDBOUNDARYPOINTS. % % TODO : This needs a bit of thinking about. The "special point" for ellipsoids % is of course the center of the ellipse. In some cases we might want to have % the user prescribe the center and in other cases we want the find the center % algorithmically. The problem is that all the parameters of the ellipsoid are % found simultaneously. % Copyright 2000-2010 The MathWorks, Inc. if isempty(X) bp = []; ok = false; return end Xc = pFilterFactors( con, X ); % Find the minimal enclosing ellipse [xc, L, bp] = xregfindcenter( Xc, 'MinEllipse', i_GetFminconOptions( opts ) ); % Constraint settings con.xc = xc; con.W = L' * L; con.scalefactor = 1.0; % make sure all X are inside the boundary md = max(constraintDistance(con,X)); if md>0 con.Offset = 2*md; end ok = all(isfinite(L(:))); %-------------------------------------------------------------------------- function options = i_GetFminconOptions( om ) options = optimset( fmincon( 'defaults' ), ... 'largescale','off',... 'Algorithm','active-set',... 'Display', get( om, 'Display' ), ... 'MaxFunEvals', get( om, 'MaxFunEvals' ), ... 'MaxIter', get( om, 'MaxIter' ), ... 'TolFun', get( om, 'TolFun' ), ... 'TolX', get( om, 'TolX' ), ... 'TolCon', get( om, 'TolCon') ); %-------------------------------------------------------------------------- % EOF %--------------------------------------------------------------------------