Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 18 de Ag. de 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 comentarios
Walter Roberson
Walter Roberson el 18 de Ag. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by