MATLAB: Best way of drawing multiple circles and updating their position

MATLABplot

What is the best way to draw a variable number of circles in a plot and update their position?
I have tried
F = rectangle('Position', [(Xpositions - radius) ...
(Ypositions - radius) radius*2 radius*2], ...
'Curvature', [1, 1], 'LineStyle', '--', ...
'EdgeColor', 'r', 'LineWidth', 3);
but since I have multiple circles I would have to create a for loop to draw each circle.
F = viscircles([Xpositions, Ypositions], ...
radii, 'LineStyle', '--', 'EdgeColor', 'r', 'LineWidth', 3);
seems to work fine and draw the circles, but it does not provide of a way to update the positions of the circles.

Best Answer

The easiest is to use rectangle() and use handle F to update the Position property
F.Position = [x y r r]; % specify a new psition

F.Position = [x_ y_ r_ r_]; % specify a new psition
everytime you update Position property, the figure will be updated with the new position.
In older MATLAB version use
set(F, 'Position', [x y r r])
In case of for loop, create an array of handles,
% inside for loop
F(i) = rectangle('Position', [(Xpositions - radius) ...
(Ypositions - radius) radius*2 radius*2], ...
'Curvature', [1, 1], 'LineStyle', '--', ...
'EdgeColor', 'r', 'LineWidth', 3);
and then set the property using F(1), F(2), ... instead of F to change a particular circle.