MATLAB: Detect points in predefinied distnace in array

distancematrix distancepoint

Hello
I have a simple question but I can not find its solution.
I have a predefined point in an array (Xo,Yo) and I need to detect the points that lie within a distance D from (Xo,Yo). Is there any simple way to do this ?
By looking into availabe funcitons of Matlab I step upon ExhaustiveSearcher() but I think is quite complicated to use for such a simple process !
Is there any other function I am missing ?
Thank you in advance !

Best Answer

allPixels = rand(1000, 2);
point = [0.5, 0.6];
radius = 0.1;
% Squared Euclidean distance:
dist_2 = sum(bsxfun(@minus, allPixels, point) .^ 2, 2);
near = dist_2 <= (radius .^ 2);
Now near is TRUE for all pixels inside the radius around the point.