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.
Faez Alkadi
Faez Alkadi 2017 年 8 月 18 日
Thank you so much Walter its working now

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by