Making a circle with circles

2 次查看(过去 30 天)
Nicholas Deosaran
Nicholas Deosaran 2020-10-13
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 中查找有关 2-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