Making a circle with circles
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Mathieu NOE
el 13 de Oct. de 2020
hello
sorry I don't understand your problem
can you reformulate it please ?
Respuestas (1)
Athul Prakash
el 16 de Oct. de 2020
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!
0 comentarios
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!