How to return data points without the detected once while using Rangesearch function.

3 views (last 30 days)
How to get red of the detected data points in the matrix [x y] (The points with in the range 0.5) and make the next code returns a new matrix [X Y] withOUT the detected ones with in the range 0.5 .
x = gallery('uniformdata',30,1,1);
y = gallery('uniformdata',30,1,10);
k = boundary(x,y);
hold on;
%%get points at distance 0.5 from boundary
idx = rangesearch([x y],[x(k) y(k)],0.5);
% plot the points
N = length(k) ;
for i = 1:N
plot(x(idx{i}),y(idx{i}),'O','color',rand(1,3)) ;
Thank you

Accepted Answer

Walter Roberson
Walter Roberson on 18 Aug 2017
points_within_range = unique([idx{:}]);
temp_matrix = [x, y];
output_matrix = temp_matrix(~points_within_range, :);
In my test, the resulting output matrix is empty, because with that distribution of points, every point is within 0.25 of some edge point. The average distance to some edge point was about 0.11

Sign in to comment.

More Answers (0)


Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by