www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/+mbcmodelview/@OutlierLine/click.m

    function click(OL, lineH)
% OUTLIERLINE/CLICK
%
% CLICK(LINE, [], OL)
% CLICK is the line callback from one of the OL lines.
% New outlier added or current outlier removed from all OL lines
% OL userdata updated accordingly

%  Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc.



% find the point index in the data of the line that we have clicked on.
ax = OL.lineParents(OL.lineHandles==lineH);
pos=get(ax,'CurrentPoint');
pos=pos(1,1:2);
xdata=get(lineH,'XData');
ydata=get(lineH,'YData');
metric=((xdata-pos(1))./diff(get(ax,'XLim'))).^2 + ...
	((ydata-pos(2))./diff(get(ax,'YLim'))).^2;
[~,pt_ind]=min(metric);
if isempty(pt_ind)
	return
end

OL.outlierIndices= setxor([OL.outlierIndices],pt_ind);
% %% outlierIndices listener changes calls redraw callback