3

In working with MATLAB's uitab, I had two specific questions:

  1. How do I remove a tab that has been created using uitab function?

  2. How do I clear the contents of such a tab (including diagrams, buttons, etc.) without deleting the tab itself?

Suever
  • 64,497
  • 14
  • 82
  • 101
Feri
  • 1,071
  • 7
  • 19

1 Answers1

2

In order to remove a uitab from a uitabgroup but not delete the graphics object, you can change the 'Parent' property to [].

hgroup = uitabgroup();

htab = uitab(hgroup, 'Title', 'Tab');

button = uicontrol('Parent', htab, 'String', 'Button');

% Don't show the uitab
set(htab, 'Parent', []);

Then if you want to display the tab again, change the 'Parent' property back to the tab group that you'd like it to belong to.

set(htab, 'Parent', hgroup)

If you want to clear a tab, you can delete all of the 'Children' of that tab

delete(get(htab, 'Children'))
Suever
  • 64,497
  • 14
  • 82
  • 101
  • Thank you! I have another problem now. When I want to plot to the tab that I have removed the content of, nothing is displayed. (But surprisingly, the ui controls are displayed). What's the problem? – Feri Nov 25 '16 at 15:37
  • 1
    Are you creating a new `axes` object in the tab prior to trying to plot to it? If you don't, the plots will just go to the current axes which may exist somewhere else. – Suever Nov 25 '16 at 15:54