function yn = rmpoints(x,y)
%function yn = rmpoints(x,y)
% This cleans up points in y array.
% Point to outliers with the cursor and click it.
% If you click close enough to the point a large dot is put over the point
% All clicks spawn stars, but only large dots are marked as NaN
% The y value at that point is replaced with NaN
% Run fixnan.m on the output to spline fill those points
% Click to a small outside of graph x value to terminate the program

plot(x,y,'.',x,y)
hold on
another = 1
yn = y;
xmin = min(x);
xmax = max(x);
xrange = (xmax-xmin)/100.
ymin = min(y);
ymax = max(y);
yrange = (ymax-ymin)/100.

while another==1

[x1,y1] = ginput(1);
plot(x1,y1,'*')

if (x1<xmin-xrange), break, end
llx = find(x > x1-xrange);
lmx = find(x < x1+xrange);
l = min(llx):max(lmx);

ll = find(y(l) > y1-yrange);
if length(ll) == 1 ,
ll = l(ll);
else
lm = find(y(l(ll)) < y1+yrange);
l = ll(lm);
ll = l+min(llx)-1;
end

if abs(yn(ll) - y1) < yrange*2 ,

      yn(ll) = NaN;
      plot(x(ll),y(ll),'o')
end

end

hold off
