Deleting a rectangle created in one function from another function

1 回表示 (過去 30 日間)
Jason
Jason 2017 年 3 月 11 日
編集済み: Jason 2017 年 3 月 11 日
If I create a rectangle on an image from one function via:
function1(handles)
axes(handles.axes1);
hr=rectangle('Position',position,'EdgeColor','y')
How do I delete it from another function. I have tried both
function2(handles)
hl = findall(handles.axes1, 'type', 'line')
h2=( findobj(handles.axes1, 'type', 'line') )
delete(hl);
delete(h2)
drawnow
But both h1 & h2 are empty:
hl =
0×0 empty GraphicsPlaceholder array.
h2 =
0×0 empty GraphicsPlaceholder array.
  1 件のコメント
Jason
Jason 2017 年 3 月 11 日
編集済み: Jason 2017 年 3 月 11 日
Done it.
hl = findall(handles.axes1, 'type', 'rectangle')

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

採用された回答

Jason
Jason 2017 年 3 月 11 日
編集済み: Jason 2017 年 3 月 11 日
hl = findall(handles.axes1, 'type', 'rectangle')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by