function [chosen,others]=sel_pts(x,y)
%function [chosen,others]=sel_pts(x,y)
%
%This tool will plot x and y as light blue circles on your current plot-
%	if "hold" is on, it will plot on top of what is there
%	if "hold" is off, if will make a new plot with x and y
%	you then go into you plot and click on the points of interest
%	--> "chosen" is the array of indices into (x,y) you clicked on
%	--> "other" is everything else
%input x and y, and it will output the indices to the points you clicked on
% [chosen,others]=sel_pts(x,y);

%comments to Jules Hummon (95/09/12)
zoom off
x=x(:);
y=y(:);

plot(x,y,'co')
index=ones(length(x),1);
disp('click on bad points - HIT return when done')

chosen=[];
[bad_x, bad_y] = ginput;  % get bad points with mouse

for i=1:length(bad_x)
	dist=sqrt((bad_x(i)-x).^2 + (bad_y(i)-y).^2);
	newchosen=find(dist==min(dist));
	if (length(newchosen)>1)
		disp(['-------> warning: duplicate point at:'])
		disp(['x= ',num2str(bad_x(i)),'; y= ',num2str(bady(i))])
	end
	chosen=[chosen;newchosen];
end

hold on
plot(x(chosen),y(chosen),'m*')


index(chosen)=0*chosen;		%discard the chosen ones

others=find(index==1);


disp('zoom is off')