- One of the parameters you can set is whether the circles extend beyond the chosen border or not.
- At the top of the code, in the comment section, I give an example of how to calculate the area of the circles by using the function outputs.
non overlapping random circles
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
jahanzaib ahmad
el 20 de Feb. de 2019
Comentada: Adam Danz
el 22 de En. de 2021
in search of a code which can generate output like this on matlab . and the result is in polyshapes ,centre and radius
circles are randomly distributed at the periphery of square .
input is number of circels,max radius , minimum radius and area of circles
0 comentarios
Respuesta aceptada
Adam Danz
el 20 de Feb. de 2019
Editada: Adam Danz
el 21 de Feb. de 2019
The FEX contribution metioned by Matt J produces cirlces that are closely packed. I wrote an alternative function that plots circles with random centers that do not overlap but do not have the requirement to be densely packed. That function can be downloaded here:
Here are some notes that pertain to your needs:
Please feel free to play around with that function and its options. If you have any further question or problems, please follow up here.
Below are some examples produced by this funciton.
*A previous version of this solultion included the source code. I've since edited that code and uploaded it to the file exchange.
10 comentarios
DIVAKAR RAJU P V
el 21 de En. de 2021
can we maintain periodicity here. cutout portion of boundary should fall on opposite side
Adam Danz
el 22 de En. de 2021
Yes, starting in bubblebath() vs 2.3.0 you can set edgeType=3 to wrap circles that expand beyond the frame edge.
Example:
rng('default') % for reproducibility
S = struct();
S.frameSize = [30 30];
S.circSize = 4;
S.nSizes = NaN;
S.edgeType = 3; % <-- flag to wrap edges
S.supressWarning = true;
bubblebath(S)
Ver también
Categorías
Más información sobre Elementary Polygons 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!