MATLAB: Does the Callback function of a uicontrol object still exist after deleting the object in GUIDE using MATLAB 7.0.4 (R14SP2)

m-fileMATLABupdate

Reproduction steps:
1.Create a GUI in GUIDE with several uicontrol objects, some of which have associated Callback functions.
2. Delete the uicontrol objects in GUIDE and then save the GUI.
The Callback functions still exist in the file that GUIDE created.

Best Answer

The ability to automatically remove Callback functions associated with deleted uicontrol objects is not available in GUIDE in MATLAB 7.11 (R2010b).
To work around this issue, you can delete the Callback functions manually.
The Callback code is not deleted automatically so that it may be reused for other uicontrols. For example, suppose I have a huge code for a callback function that is called when a PushButton is pressed. Now, suppose I wish to replace the Pushbutton with a checkbox, but have the same implementation of the callback. In such cases, I can assign the callback function to the new uicontrol. Automatically deleting Callback functions could cause valuable code to be deleted.