Finding number of points inside a circle and assign them into a matrix

Hi guys,
I have a grid of dots (x,y) which lies on a plane, I am creating circles in the same plane which I know both radius and center coordinates of circle.
What I am trying to do is create a new matrix of (x,y) coordinates of dots which are inside the circle.
Thanks in advance

 採用された回答

bym
bym 2012 年 7 月 27 日

2 投票

one way to do it:
clc;clear
xy = rand(100,2);
plot(xy(:,1),xy(:,2),'b.')
hold on
t = linspace(0,2*pi);
plot(.5+.25*cos(t),.5+.25*sin(t),'r-')
axis square
r = hypot(xy(:,1)-.5,xy(:,2)-.5);
plot(xy(r<=.25,1),xy(r<=.25,2),'go')

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

E K
2012 年 7 月 27 日

コメント済み:

m
m
2016 年 11 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by