%Used to test the new version of closest.m against the old one.

m = 100;
n = 200;
x = rand(m, n);
%x  = (x>.5);
y = rand(m, n);
%y  = (y>.5);
xi = .3;
yi = .4;

tic
[i, j] = closest(x, y, xi, yi)
toc
xi - x(i, j)
yi - y(i, j)

tic
[i, j] = closest1(x, y, xi, yi)
toc
xi - x(i, j)
yi - y(i, j)

xx = ones(m, n);
yy = ones(m, n);

tic
[i, j, i_extra, j_extra, index_marker] = closest1(xx, yy, xi, yi);
toc
xi - xx(i, j)
yi - yy(i, j)

xi = [.2 .3 .5];
yi = [.6 .7 .8];
tic
[i, j, i_extra, j_extra, index_marker] = closest1(xx, yy, xi, yi);
toc

xi = [.2; .3; .5];
yi = [.6; .7; .8];
tic
[i, j, i_extra, j_extra, index_marker] = closest1(xx, yy, xi, yi);
toc

% xi - xx(i, j)
% yi - yy(i, j)

