www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@constar/findSpecialPoints.m
function [con, sp, ok] = findSpecialPoints(con, opts, X) %FINDSPECIALPOINTS Find special points for a star shaped constraint % % [CON, SP, OK] = FINDSPECIALPOINTS(CON, OPTS, X) % % See also CONSTAR, CONBASE/FINDSPECIALPOINTS. % Copyright 2005-2009 The MathWorks, Inc. and Ford Global Technologies, Inc. sp = []; ok = true; X = pFilterFactors( con, X ); centerAlg = get( opts, 'CenterAlg' ); switch getname( centerAlg ), case 'Mean', sp = mean( X,1 ); case 'Median', sp = median( X, 1 ); case 'Mid Range', sp = 0.5 * (max( X,[],1 ) + min( X,[],1 )); case 'Min Ellipse', sp = xregfindcenter( X, 'MinEllipse' ); case 'User Defined' sp = i_ExtractUserDefinedCenter( centerAlg, nActiveFactors( con ) ); otherwise warning(message('mbc:constar:InvalidArgument', getname( centerAlg ))); end if ok, con.Center = sp; end %-------------------------------------------------------------------------- function sp = i_ExtractUserDefinedCenter( om, n ) try sp = get(om,'CenterPoint'); catch ME % old option parameters were P1, P2, .. Pn sp = zeros( 1, n ); for i = 1:n, sp(i) = get( om, sprintf( 'P%d', i ) ); end end if length(sp)~=n error(message('mbc:constar:InvalidState')); end %-------------------------------------------------------------------------- % EOF %--------------------------------------------------------------------------