How to find 2D data points within a specific distance (in X and Y) to the inside direction along boundary line ?

4 ビュー (過去 30 日間)
In 2D data that has a boundary. How to find data points(x,y) which are laying within specific range from the boundary. For example :
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));
So, how can we get the data points(x,y) laying within distance of 0.5 in both directions x and y from the inside wall along the boundary. In other words, How can I get data points(x,y) that is (0.5 or less) away from the inside of the boundary wall in any direction (x,y).
Thanks

採用された回答

KSSV
KSSV 2017 年 8 月 3 日
Read about rangesearch
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
  2 件のコメント
Faez Alkadi
Faez Alkadi 2017 年 8 月 3 日
編集済み: Faez Alkadi 2017 年 8 月 3 日
Thank you so much KSSV,
One more question please,
Do you know how can I delete this detected data points from the original matrix [x y] withOUT deleting boundary points with it. And make the code return NEW [X Y] matrix without detected points?
I added this to the for loop but didn't work:
for i = 1:N
X=(x(idx){i});
Y=(y(idx){i});
plot(x(idx{i}),y(idx{i}),'O','color',rand(1,3)) ;
end
Best
John D'Errico
John D'Errico 2017 年 8 月 3 日
The nice thing about Answers is all of us can learn from it. I never saw rangesearch until now. Learn something new everyday.

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

その他の回答 (1 件)

Faez Alkadi
Faez Alkadi 2017 年 8 月 16 日
Thank you so much KSSV,
One more question please,
Do you know how can I delete this detected data points from the original matrix [x y] withOUT deleting boundary points with it. And make the code return NEW [X Y] matrix without detected points?
I added this to the for loop but didn't work:
for i = 1:N
X=(x(idx){i});
Y=(y(idx){i});
plot(x(idx{i}),y(idx{i}),'O','color',rand(1,3)) ;
end
Best

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by