How to plot multiple circles within a circle by using a for-loop for radius/center position?
23 views (last 30 days)
I want to plot multiple equisized small circles filling within a sector bigger circle.
The center of each of the smaller circle changes as radial distance with respect to the center of bigger cirlce, as can be seen from the attached image. And the smaller circles are to be filled with color map, ranging from 0 to 1.
This entire plotting will then be in a time loop from 1 to 100 sec.
It will be of great help if anyone can share thoughts, and if possible, brief code.
Johan on 27 Sep 2021
I have been working with somewhat similiar plotting needs. To plot circles I used the polyshape built-in function with the code below. With this function you can directly call plot(CoordCircle(radius,xcenter,ycenter) and update your plot following your needs. You can look up the polyshape function for details on plotting, you can change transparency and color as suits your need.
function RES = CoordCircle(r,x0,y0)
t = 0:0.05:2*pi;
x1 = r*cos(t)+x0;
y1 = r*sin(t)+y0;
RES = simplify(polyshape(x1,y1));
To make your time depend representation, I would start by plotting all the circles you want, compute the new radii then update your plotted circle by using the figure handle, clf and drawnow function.
Hope this helps,
More Answers (1)
Image Analyst on 27 Sep 2021
If you have a list of the centers and radii, and the Image Processing Toolbox, I'd simply use the function meant for displaying circles: viscircles()
Lots of options you can use to change the way the circles look (color, linewidth, etc.), so look into those.