I am trying to make an animation with circles obtained with the rectangle function in Matlab2013. In order to animate the plot, I tried using clf
, drawnow
and pause
, but it does not seem to work. On the other hand, when I work with dots or lines, I use set
and pause
and it works fine, but I do not see a way to use these with rectangles.
Here, I show you how I tried to do it with drawnow
. There are 1000 time steps, and at every time step I have stored the x
and y
coordinates of four circles.
%At every time step I would like to plot 4 circles.
PosxProt = rand(1000, 4)
PosyProt = rand(1000, 4)
for i=1:1000
clf
hold on
for j=1:4
rP=0.345; %radius of the circles
cP=[PosxProt(i,j) PosyProt(i,j)]; %center of the circles
rectangle('Position',[cP-rP 2*rP 2*rP],'Curvature',[1 1],'facecolor','r') %plot circle
end
drawnow
pause(0.05)
end