필터 지우기
필터 지우기

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