Reusing deleted figure handle
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a GUI which displays several axes (array of axes) that the user can switch between to plot on. Here's what the relevant portion looks like:

The issue I'm running in to is that I have a delete button (not shown) which deletes an axes using delete(handle), but I'd like to implement an undo button (not shown). When an axes is deleted, the code stores it and the index in the array in case the user undoes the operation. During the undo, the deleted axes is restored to the previous location in the array. There's a line of code:
axes(plotWindow.plot(lastAxesInd));
%plotWindow is the GUI
%plotWindow.plot is the array of plots
%lastAxesInd is the index of the axes which was deleted. it is being inserted back to the same location
which is meant to switch the focus of the GUI to the restored axes. This causes Matlab to crash, which I'm assuming is because I'm trying to switch focus to a handle which has been deleted.
What can I do to go around this issue? I'd like to not have to append a new axes to the end of the array, since I use the axes' indices as a way to track which plot the user is plotting on, shown above.
5 commentaires
Adam
le 7 Oct 2015
I don't really know what the overhead is of non-visualised axes, though it depends more what is plotted on them since the data will remain in memory.
Permanently deleting all previously deleted axes is easy though. As I said, so long so long as you keep the index of the one the user just selected to delete you can hide that one, but delete the previously "hidden" one because it can now never be restored by the user. Just don't physically delete the very latest one that might be restored.
Réponse acceptée
Stephen23
le 7 Oct 2015
Modifié(e) : Stephen23
le 7 Oct 2015
How about simply keeping all of the axes (no deleting!) and switching the axes' visibility property on and off? Then all of your axes handles remain valid for as long as the axes exist, even if they are not visible.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!