Filled circles with different colors

Hello, I know the radius and the center coordinate of many circles
I want to plot these circles as filled circles and each circle has a color different to the others. I used this function to plot them but I cannot obtain filled circles.
function circle(x,y,r)
%x and y are the coordinates of the center of the circle
%r is the radius of the circle
%0.01 is the angle step, bigger values will draw the circle faster but
%you might notice imperfections (not very smooth)
ang=0:0.01:2*pi;
xp=r*cos(ang);
yp=r*sin(ang);
plot(x+xp,y+yp);
end
Can someone help me to do this? Thanks

Answers (1)

doc patch . USe patch instead of plot to fill the color.
r = 1. ;
th = linspace(0,2*pi) ;
x = r*cos(th) ;
y = r*sin(th) ;
patch(x,y,rand(1,3)) ; % I am using random color in patch here.
axis equal

Asked:

on 9 Jul 2017

Answered:

on 10 Jul 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!