Deleting circles drawn using viscircles

15 ビュー (過去 30 日間)
Vance Blake
Vance Blake 2019 年 8 月 19 日
コメント済み: Vance Blake 2019 年 9 月 13 日
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 ??
Before:
After:
  2 件のコメント
Adam
Adam 2019 年 8 月 19 日
Deleting handles returned from viscircles works fine when I try it, but I don't know how you are using it specifically.
Vance Blake
Vance Blake 2019 年 8 月 19 日
編集済み: Vance Blake 2019 年 8 月 19 日
I am using viscircles to place circles around the points on the plot. I have all the circles saved to a handle called CTR_circles1 but when i delete CTR_circles1 the circles don't disappear. the relevant parts of the code are shown below. I do this task many more times thorughout the code but for the initial time I want to use it, it doesn't work.
% plots circles centered around the randomly generated points
for i = 1:n
radii_node = 4;
centers_node = [x(i), y(i)];
CTR_circles1 = viscircles(centers_node, radii_node, 'color', 'r');
hold on
end
%%
delete(CTR_circles1);

サインインしてコメントする。

採用された回答

Adam Danz
Adam Danz 2019 年 8 月 19 日
編集済み: Adam Danz 2019 年 8 月 20 日
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).
Instead,
% plots circles centered around the randomly generated points
CTR_circles1 = gobjects(1,n); % or (n,1)
hold on
for i = 1:n
radii_node = 4;
centers_node = [x(i), y(i)];
CTR_circles1(i) = viscircles(centers_node, radii_node, 'color', 'r');
end
%%
delete(CTR_circles1);
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');
  24 件のコメント
Adam Danz
Adam Danz 2019 年 9 月 13 日
How about we start a new question since we've diverged a bit from the original topic which may make the thread difficult to follow?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by