Deleting circles drawn using viscircles
24 views (last 30 days)
Hello, I am trying to delete a group of circles drawn on my plot using viscircles. I have saved the group to a handle, but when I try to execute the delete(handle) command the circles still remain. I am using 'hold on' to continuously update the same figure could that be interfering? The points that the circles surround are removed when I delete their handle. below is a picture of before and after I run the delete(handle) commands. Would usign data linking/sourcing be a better option?? Would showing the updates via a new subplot window also work ??
Adam Danz on 19 Aug 2019
Edited: Adam Danz on 20 Aug 2019
The handles are being overwritten on each iteration of the i-loop so at the end of the loop, you only have access to the last drawn cirlcle(s).
% plots circles centered around the randomly generated points
CTR_circles1 = gobjects(1,n); % or (n,1)
for i = 1:n
radii_node = 4;
centers_node = [x(i), y(i)];
CTR_circles1(i) = viscircles(centers_node, radii_node, 'color', 'r');
Or better yet, use input matrices to avoid the loop.
centers_node = [x(:), y(:)];
radii_node = 4 * ones(size(centers_node,1),1);
CTR_circles1 = viscircles(centers_node, radii_node, 'color', 'r');