function ind = pointToInd(uDat)
%This function prompts the user to select a point on the most recently open
%graph. It returns the index of the point closest to a point in uDat

%perform a coarse search based on x position
[x y] = ginput(1);
[val sInd] = min(abs(uDat(1,:) - x));

%do a fine search over '2w+1' indices, using actual distance
w = 2;
tSet = uDat(:,(sInd-w):(sInd+w));
res = zeros(1,2*w+1);
for fi = 1:(2*w+1) 
    res(fi) = sqrt((tSet(1,fi)-x).^2 +(tSet(2,fi)-y).^2);
end
[val tInd] = min(res);

%convert fine search index to real index
ind = sInd+(tInd-(w+1));