フィルターのクリア

I want to create a circle of radius 5 and then inside this circle 3 more circles of radius 1 with different centers and then generate random points in each circle separately?please help

1 回表示 (過去 30 日間)
I want to create a circle of radius 5 and then inside this circle 3 more circles with different centers of radius 1 and then generate random points in each circle separately?please help. I need to access the points of each circle separately like user co ordinate in circle 1,2 and 3. User co ordinate of bigger circle should be accessible.

採用された回答

KSSV
KSSV 2018 年 6 月 6 日
N = 200 ;
R = 5 ;
C = [0 0] ;
th = linspace(0,2*pi,N) ;
xc = C(1)+R*cos(th) ;
yc = C(2)+R*sin(th) ;
%
R1 = 1 ;
% get three centers inside the circel
a = -R+R1 ; b = R-R1 ;
x = (b-a).*rand(3,1)+ a;
y = (b-a).*rand(3,1)+ a;
% get each cricle
figure
hold on
plot(xc,yc) ;
plot(x,y,'.r')
cx = zeros(3,N) ;cy = zeros(3,N) ;
for i = 1:3
cx(i,:) = x(i)+R1*cos(th) ;
cy(i,:) = y(i)+R1*sin(th) ;
plot(cx(i,:),cy(i,:),'r')
end
% Generate random numbers inside each circle
M = 100 ;
a = -R1 ; b = R1 ;
rr = cell(3,2) ;
for i = 1:3
rx = x(i)+(b-a).*rand(M,1)+ a;
ry = y(i)+(b-a).*rand(M,1)+ a;
idx = inpolygon(rx,ry,cx(i,:),cy(i,:)) ;
rr{i} = [rx(idx) ry(idx)] ;
plot(rx(idx,:),ry(idx,:),'.','color',rand(1,3))
end
  1 件のコメント
RADHIKA GOUR
RADHIKA GOUR 2018 年 6 月 6 日
編集済み: RADHIKA GOUR 2018 年 6 月 6 日
Thank you. This is what I want. But I also want to generate points inside the biggest circle and these points should not go in smaller circles.

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by