Code to draw multiple circles that do not overlap
Mostra commenti meno recenti
In Matlab, I try to draw circles randomly as shown in the following figure.

The current situation is drawn like this and I am in trouble because I have no idea how to make it a circle.

%the code of the current situation
t = linspace(0,2*pi,100);
figure
cx = 200 + (rand(20, 1) .* 1000); %center of the circle
cy = 300 + (rand(20, 1) .* 1000); %center
r = 2; %radius
plot(r*sin(t)+cx,r*cos(t)+cy)
y = r*cos(t)+cy
x = r*sin(t)+cx
for i =0:20
fill(x,y,'k')
%fill(r*sin(t)+cx,r*cos(t)+cy, 'k')
r = r+1;
end
i=i+1;
axis([0,1200,0,1200])
axis square
Risposta accettata
Più risposte (1)
H Y
il 12 Gen 2018
0 voti
Categorie
Scopri di più su 多角形 in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!