Making a circle with circles
3 ビュー (過去 30 日間)
古いコメントを表示
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
2020 年 10 月 13 日
hello
sorry I don't understand your problem
can you reformulate it please ?
回答 (1 件)
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!
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!