testindices = find(zoriglong == matchpos);
tzp = zpos(testindices);
tzd = zdirs(testindices);
tsonars = sonars(testindices);

% map includes all data appearing earlier (closer to origin) in map
% that test sample
mapindices = [1:(min(testindices)-1)];
mzp = zpos(mapindices);
mzd = zdirs(mapindices);
