フィルターのクリア

How to undo a plot for multiple times?

9 ビュー (過去 30 日間)
Ali Y.
Ali Y. 2015 年 8 月 13 日
コメント済み: Ali Y. 2015 年 8 月 13 日
I want to delete a scatter plot's items for multiple times. My code is like
Function plot_callbacks (hObject, eventdata, handles)
figure (5)
scatter(x,y,'x')
hold on
scatitem = get(gca, 'Children');
handles.scatitem = scatitem;
guidata(hObject,handles)
Function undo_callbacks (hObject, eventdata, handles)
scatitem = handles.scatitem;
should_continue = true
while true
delete(scatitem(1))
scatitem(1) = []
should_continue = 0
end
In the second callback function, the line
delete(scatitem(1))
, just by it-self, deletes the last item, but just for one time. By the second function, I am trying to do the deletion for several times.
Does anyone know where did I write the code incorrectly? How can I make it working?

採用された回答

Walter Roberson
Walter Roberson 2015 年 8 月 13 日
編集済み: Walter Roberson 2015 年 8 月 13 日
function undo_callbacks (hObject, eventdata, handles)
scatitem = handles.scatitem;
number_to_delete = 3; %for example
delete(scatitem(1:number_to_delete))
scatitem(1:number_to_delete) = [];
handles.scatitem = scatitem;
guidata(hObject, handles);
end
If you only want to undo one per call, change the 3 to 1.
The difference compared to your code is that my code updates handles.scatitem . You were trying to delete the same child every time
  1 件のコメント
Ali Y.
Ali Y. 2015 年 8 月 13 日
Thank you very much, Wlater.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by