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

1 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2017-8-18
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 个评论
Walter Roberson
Walter Roberson 2017-8-18
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by