# How to plot (n) circles with known center and radius

조회 수: 3 (최근 30일)
Abdul Hamed Hatem 2020년 7월 4일
댓글: Abdul Hamed Hatem 2020년 7월 4일
Hi,
I need to generat a plot of (n) circles. The radius of the circles is known and equals to 15m. The circles centers are separated by azimuthal angle equal to 10 degrees and they are located on the perimiter of biggr circle that it is radius is 120m.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
theta=10 % azimuthal distance between the centers of circles group
r=120 % The radius of the big circle
DM=12 % The radius of the group of circles
for i=1:38 % number of circles
x1(i)= r*cosd(90-(i-1)*theta); % the x comoenets of the circle group
y1(i)=r*sind(90-(i-1)*theta); % The y component of the circle group
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Best Regards,

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

### 채택된 답변

Image Analyst 2020년 7월 4일
If you have the Image Processing Toolbox, use viscircles(centers, radii):
theta=10 % azimuthal distance between the centers of circles group
r=120 % The radius of the big circle
DM=12 % The radius of the group of circles
numCircles = 38;
for k = 1 : numCircles % number of circles
xCenter(k) = r * cosd(90-(k-1)*theta); % the x comoenets of the circle group
yCenter(k) = r * sind(90-(k-1)*theta); % The y component of the circle group
end
plot(xCenter, yCenter, 'b.');
grid on;
viscircles([xCenter(:),yCenter(:)], 15 * ones(numCircles, 1));
axis square
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Abdul Hamed Hatem 2020년 7월 4일
Many Thanks,
That is exactly what I want.
Regards,

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

### 추가 답변 (1개)

Rafael Hernandez-Walls 2020년 7월 4일
I don't know is you want this:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
theta=10 % azimuthal distance between the centers of circles group
r=120; % The radius of the big circle
DM=15; % The radius of the group of circles
i=1:38;
x1= r*cosd(90-(i-1)*theta); % the x component of the circle group
y1= r*sind(90-(i-1)*theta); % The y component of the circle group
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
plot(x1,y1),axis equal
hold on
n=38;
for k=1:n
x=x1(k)+DM*cos([0:pi/16:2*pi]);
y=y1(k)+DM*sin([0:pi/16:2*pi]);
plot(x,y);
drawnow
end
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Abdul Hamed Hatem 2020년 7월 4일
Many thanks Rafael,
Yes, that is what I am looking after.
Regards,

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

### 카테고리

Help CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by