MATLAB: How to locate the coordinates of a calculated distance below a certain threshold

distance formulafor looplogical indexingloopsMATLAB

I'll try to be as detailed as possible here:
I have two matrices with coordinates. Once matrix has coordinates of line intercepts of a synthetic microstructure, and one matrix has the coordinates of triple points of grain boundaries. The matrices are never guaranteed to be the same size. For example, the matrices would look similar to:
tpoint = [1 2
4 5
7 8
10 11];
xyints = [12 16
2 18
24 19];
Side note: in some instances, 'xyints' could be larger than 'tpoint', since I am randomly generating lines across the microstructure and the number of intercepts will vary with each run of the script, but the number of triple points is constant. The matrices listed above are just general examples; the real ones have 100+ ordered pairs within each matrix.
Essentially what I need to do is start with the first coordinate of the 'tpoint' matrix and calculate the distance between that point and each of the coordinates of the 'xyints' matrix. Here is the code I currently have to loop between 'tpoint' and 'xyints':
abc = size(tpoint);
for m = 1:abc(1)
dist = sqrt((tpoint(m,1)-xyints(1:end,1)).^2+(tpoint(m,2)-xyints(1:end,2)).^2);
end
From here, I use logical statements to find out when 'dist' is under a certain threshold, say for instance dist < 12. What I'm trying to do is locate which 'xyints' coordinates were used in the equation to produce that distance and then plot them using scatter. If any other details are needed I am happy to provide them. I am currently using the prerelease of R2020b to run this code. Any assistance you can give me is greatly appreciated.

Best Answer

Wouldn't it just be
subset = xyints(dist<12,:)