Making a circle with circles

조회 수: 4 (최근 30일)
Nicholas Deosaran
Nicholas Deosaran 2020년 10월 13일
답변: Athul Prakash 2020년 10월 16일
Hello all,
I am trying to mod my currrent function that plots a circle and fills it a color to ,ale a gird of dots that have circles with a raduis of 1.
and are located at x locations -50to 50 and y location -50 to 50, with spacing.
function circle = circleplot(x,y,r,c)
%This function makes a cirele
% By taking the inputs for location for x and y
% Also taking the input of r for the radius
% C input is for the clor
th = 0:pi/50:2*pi; %
x_circle = r * cos(th) + x; % func for x
y_circle = r * sin(th) + y; % func for y
circle = plot(x_circle, y_circle); %to plot the 1st circle
hold on % keep axis on to plot 2nd circle
fill(x_circle, y_circle, c) % To fill the circle with your clor
plot(x, y, 'kp', 'MarkerSize',15, 'MarkerFaceColor','g')% Puts a maker in the center of the 2nd circle.
axis equal % keeps the axis equal to fit the circle.
xlabel ('x axis');
ylabel ('y axis');
title ('Circles');
end
  댓글 수: 1
Mathieu NOE
Mathieu NOE 2020년 10월 13일
hello
sorry I don't understand your problem
can you reformulate it please ?

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

답변 (1개)

Athul Prakash
Athul Prakash 2020년 10월 16일
Hi Nicholas,
I'm assuming you want smaller circles (r=1) to be arranged in a circular shape, i.e. where they form the perimenter of a larger circle.
You may try:
1) Obtaining the centres on the outer circle. Use r*cos(theta) and r*sin(theta) like you did in your own code, but for larger spacing of theta, since we need to fit unit circles in between.
2) For each calculated centre, plot smaller circles at that point. You already have a function for that. [Keep hold 'on' so that each plot accumulates in your figure.]
**You may need to calculate the number of centres on the outer circle depending on the radius of that circle - since too many points would mean the inner circles overlap and too few would leave large gaps between the smaller circles.
Hope it helps!

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by