필터 지우기
필터 지우기

I need help to plot circle around the points and these points are in a circle. please response

조회 수: 16 (최근 30일)
this code will generate points in a particular area
n=10; % number of points that you want
center = [2 ,2]; % center coordinates of the circle [x0,y0]
radius = 10; % radius of the circle
angle = 2*pi*rand(n,1);
r = radius*sqrt(rand(n,1));
X = r.*cos(angle)+ center(1);
Y = r.*sin(angle)+ center(2);
plot(X,Y,'.r')
and here is the circle can be drawn as...
center = [2 ,2]; % center coordinates of the circle [x0,y0]
radius = 10; % radius of the circle
angle = 0:.01:2*pi;
r = radius;
X = r.*cos(angle)+ center(1);
Y = r.*sin(angle)+ center(2);
plot(X,Y,'.r')
Problem is that I want to plot circles around each point which are lying inside a given circle. Please help

채택된 답변

KSSV
KSSV 2016년 10월 5일
n=10; % number of points that you want
center = [2 ,2]; % center coordinates of the circle [x0,y0]
radius = 10; % radius of the circle
angle = 2*pi*rand(n,1);
r = radius*sqrt(rand(n,1));
X = r.*cos(angle)+ center(1);
Y = r.*sin(angle)+ center(2);
plot(X,Y,'.r')
hold on
%%Draw circle
R = 1. ; % radius
th = linspace(0,2*pi) ;
for i = 1:length(X)
x = R*cos(th)+X(i) ;
y = R*sin(th)+Y(i) ;
plot(x,y,'b')
end
hold on
center = [2 ,2]; % center coordinates of the circle [x0,y0]
radius = 10; % radius of the circle
angle = 0:.01:2*pi;
r = radius;
X = r.*cos(angle)+ center(1);
Y = r.*sin(angle)+ center(2);
plot(X,Y,'.b')
  댓글 수: 2
Praveen Pawar
Praveen Pawar 2016년 10월 5일
편집: Praveen Pawar 2016년 10월 14일
Thank you very much, sir, I tried it myself and it works,, again thanks for your response.
% code
x =2; y = 2; r=10;
th = 0:.01:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
plot(xunit, yunit)
hold on
plot(x, y, 'gs', 'MarkerSize', 15, 'LineWidth', 2)
n=7;
radius = 10;
angle = 2*pi*rand(n,1);
r = radius*sqrt(rand(n,1));
X = r.*cos(angle)+ x;
Y = r.*sin(angle)+ y;
plot(X,Y,'+r')
for k = 1:length(X)
xc = X(k);
yc = Y(k);
theta = 0:0.01:2*pi;
rc = 2;
X1 = rc.*cos(theta)+ xc;
Y1 = rc.*sin(theta)+ yc;
plot(X1,Y1,'--k')
end
hold off
Sindhuja john
Sindhuja john 2023년 5월 30일
hi how to make a circle around the each cluster ? in random cluster.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Plot Customization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by