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

1 vue (au cours des 30 derniers jours)
Faez Alkadi le 18 Août 2017
Commenté : Faez Alkadi le 18 Août 2017
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);
plot(x,y,'.')
k = boundary(x,y);
hold on;
plot(x(k),y(k));
%%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)) ;
end
Thank you
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Walter Roberson le 18 Août 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
##### 5 commentairesAfficher 3 commentaires plus anciensMasquer 3 commentaires plus anciens
Walter Roberson le 18 Août 2017
Sorry, I lost track.
temp_matrix = [x, y];
points_not_within_range = setdiff( 1:size(temp_matrix,1), unique([idx{:}]) );
output_matrix = temp_matrix(points_not_within_range, :);
The ~ version does not work because points_within_range was a vector of indices rather than a logical vector.
Faez Alkadi le 18 Août 2017
Thank you so much Walter its working now

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by