File Exchange

image thumbnail

TabManager - Create Tab Panels (uitabgroup) from a GUIDE GUI

version (41.1 KB) by Grant
Convention based method which allows a tabbed GUI to be designed using GUIDE


Updated 10 Mar 2018

View License

This class allows users to create a GUI using GUIDE that supports a tabbed UI.
Since GUIDE doesn't directly support the uitabgroup control, this class allows tabs to be created as standard panels that are at run time converted to uitab controls.
1. Create a pane with tag set to Tab? where ? is any letter or number (e.g. TabA). This main pane should be left empty and determines the size and location of the tab group (uitabgroup)
2. Create additional panes with a tag name that starts with the name of the main pane. All other controls should be added to these panes.
3. In the Guide generated function xxx_OpeningFcn add the following:
handles.tabManager = TabManager( hObject );

Cite As

Grant (2020). TabManager - Create Tab Panels (uitabgroup) from a GUIDE GUI (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (67)

Ampt Ampt

virup Rao

Hello Grant,
Thank You for the reply and Sorry for the inconvenience caused.
Yes, He may be confused. Sorry to hear that your matlab license got expired.
Will look into the issue and see if i can fix the issue meanwhile.


Hi Virup,

Rupesh sent me m-files that relied on other m-files that were on his matlab path but were not included.

I replied to his email with instructions to check that the files sent were self contained and he replied giving me instructions on how to edit his m-files to make them work!!!

I think he was a bit confused as to how free support for a free submission works!!

It's generally not a good idea to ask someone to do work that you are unwilling to do yourself!

Since then, my Matlab license has expired so it will be difficult to assist even if you send self contained m-files.


virup Rao

Hello Grant,
Sorry to ask you this. Have you sent reply to the Rupesh question which is asked on 5th Jan 2019 and he mailed you the m files on 25th Jan 2019.
Can you please forward me that mail if you have mailed him the reply. My mail id is
I am currently looking into that issue.


Have you had a look at the example "TabManagerExample" included in the zip? Try modifying the figure TabManagerExample.fig using Matlabs "guide" program. There are also instructions at the top of TabManager.m

How can I use it? I am lost

Yanjun Han

Hello Grant,
sorry for the wrong question, not for use Tab manager, for another toolbox

Hello Grant,
I have used the tabManager to create a few TabGroups, each equipped with a SelectionChangedFcn. But sometimes it seems that the wrong function executes, e.g. on a Change in TabGroupC the tabChangedB function executes. Is there a way to prevent this? I think it happens because the tabGroups Change Position for some reason and then the wrong SelectionChangedFcn is applied to the wrong TabGroup.

Hi Grant,
I have mailed you.


Hi Rupesh, you can send to developit at

Hi Grant,
Sure. What is your email id?


Hi Rupesh, Can you email me the m & fig file that shows this problem?

Hi Grant,I have created a guide page 'pageA' having tabs TabA(Main Tab) followed by child tabs TabAchild1,TabAchild2 and TabAchild3. All these tabs are created using TabManager and they are working fine. I am using Matlab 2017a version. As part of my implementation I have a close button on each of the child tab. If I press the close button on any child tab, the 'pageA' should get closed. Basically in the callback of this button I am using command 'close(pageA);'. But i am getting an error saying 'Panel TabAchild1 must not be a child of its main pane TabA(which must be an empty panel)'. Am I missing something here?


Hi Patrick, for some reason, my comments don't seem to be saving permanently.
The example, TabManagerExample.m that is part of the submission has code on the "Main" and "Supplementary" buttons that sets the selected tab. The same property can be used to get the active/selected tab.

tabMan = handles.tabManager;
tabMan.Handles.TabA.SelectedTab = tabMan.Handles.TabA01Main;




Hi Patrick, probably obvious, but when I mentioned "the example", I was referring to the example TabManagerExample.m that is part of the submission.

Hello Grant, is there a way to get the currently active tab?

Harry Wei


Hi Sebastian, you can get the figure handles from any callback by calling
handles = guihandles

Thank you Grant,
I really appreciate your work and help for the community!
But I wonder, how could i get my handles as an input of the tabChangedCB function?
I want to change Tabs in another TabGroup depending on which tab is currently selected.
Sorry, it's not obvious to me. :)


Hi exploder123, Unfortunately, Matlab doesn't support setting size, color etc on tabs (apart from via undocumented java calls).

Hello Grant, thank you very much for this manager, this is amazing.

Is there a way to change the color of the tab heading (the small area where tab title is displayed)?

Thank you very muhc.


Hi Paul, The problem relates to the order in which Matlab adds to a parents Children array and how the tab order is the reverse of the Children array order. I've changed TabManager so that it now preserves the GUIDE tab order.


Hi Timon, thanks for your improvement suggestion and code. I've put this into the latest release (and modified the example to included nested tab groups

Hi Grant, outstanding submission. Thank you. I've noticed that when I use TabManager, the tab ordering of the individual components (i.e. which component gets focus when pressing the Tab key on the keyboard) is actually the reverse of what is shown in GUIDE's Tab Order Editor. Has anyone else noticed this, and/or have an explanation?


Works like a charm on Matlab 2017


Hi Grant,
Thank you very much for the very useful and handy tabmanager! I tried to make nested GUIs and struggled first. Then I slightly modified the function TabManager (in the for loop of the ownerPanels):
parent = get(panelOwner,'Parent');
tabGroup = uitabgroup('Parent', parent, 'Units', units, 'Position', pos, 'Tag', ownerTag );

If an owner panel is located within a tab of another tab group the new owner panel gets again the tab as a parent. If you like that too you could add this to your code.


Dear Grant,
No, I did not changed the source file Tabanager.m, exactly error is in my tabmanage.m file.
And now, the error is removed after switching my work on 2017a Matab.
You done a Great job by creating this Tab panels :)



Hi Badar,Have you renamed/changed TabManager.m? The errors you are getting are from the function/class TabManage (not TabManager). I don't think its the TabManager that is causing the problem.


Hi Grant,
I am using your Tabmanager program in my GUI, I successfully created tabs, but when I programmed components in tabs it displaying this error, and my Tanmanage.m file is blank now after run the program.
please guide me in this regard, Thanks in advance.

Error using TabManage
Too many input arguments.

Error in>@(hObject,eventdata)TabManage('edit14_CreateFcn',hObject,eventdata,guidata(hObject))
Error using TabManage
Too many input arguments.

Error in>@(hObject,eventdata)TabManage('edit13_CreateFcn',hObject,eventdata,guidata(hObject))
Error using TabManage
Too many input arguments.




Hi Donya, I've updated TabManager.m so that the background colour of a placeholder panel is now copied to its corresponding uitab.

Thanks for sharing :) I have implement it and it works fine but when I'm trying to change the color of the panels it doesn't work and it goes back to the default grey color. I was wondering if you have defined the color somewhere in your function or is something wrong with my program!

Thanks in advance :)


Hi Trung Tran, yes, you can set a callback function via the SelectionChangedFcn property of the tab group. I've updated the example (TabManagerExample.m) to show how to do this.

Trung Tran

Hi Grant,
This is a amazing. I would like to ask is it possible to execute a callback function after I select the tabe manually?


Hi Oldemonium, you probably have the panels that represent the tabs as children of the panel that represents the main pane. Drag your panels (TabA01 etc) out of the main pane (TabA) so that they're children of the figure. The new version (1.03) of TabManager that I uploaded recently generates a more descriptive error message that should make it easier to diagnose this problem.


Hi, Grant and ifree. How did toi solve your problem ? I currently have the same.

help ifree


Hi ifree, not sure why this is happening. Did you try TabManagerExample (the example included)? Did that work for you? What's different between the example and your code? You can send me your code/fig if you'd like me to work out what's happening. Send to developit at

help ifree

Hi Grant, thanks for your share. I created 3 panels in a guide figure, taged with TabA, TabA01 and TabA02, and I added
handles.tabManager = TabManager( hObject ); in the openning function, when I run it gone error. My version is 2015b,
Could you help me, thanks!

Error using handle.handle/get
Invalid or deleted object.

Error in TabManager (line 98)
panelTag = get(hPanel,'Tag');

Error in tabtest>tabtest_OpeningFcn (line 57)
handles.tabManager = TabManager( hObject );

Error in gui_mainfcn (line 220)
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});

Error in tabtest (line 42)
gui_mainfcn(gui_State, varargin{:});


Hi Hyun-Gwang, Matlab tabs have fairly limited features and I don't think you can hide/enable them.

thank you, It's nice~!!
can i use enable or visible property of a Tab?

This GUIDE Addition is absolutely incredible!

Igor Sankin

Sweet - nice and simple!

Amazing!! Really good work and simple to use. Thanks

Is there a possibility to use something like:
set(handles.tabManager.TabA02, 'Enable', 'off');
to disable specific tabs?

I get following error:
There is no Enable property on the Tab class.

Thank you

I am surprised how could MATHWORKS ignore such a basic feature in GUIDE. Thanks for sharing.


This one is amazing!
Hopefully mathworks offers offical support.

Excellent work



Hi Lico, I've updated the example to show how to select a tab from code.
tabMan = handles.tabManager;
tabMan.Handles.TabA.SelectedTab = tabMan.Handles.TabA02Supplementary;


Hi, Grant,
Thanks for your excellent job. It really helps me a lot.
There is one small question about tab manager. Is it possible to switch tab by command not by mouse click? For example, I have 3 tabs, TabA1, TabA2, and TabA3, and I would like to automatically switch to TabA2 after completing some data plotting.



Hi zijing zelan,
You can show an image in the example figure (i.e. TabManagerExample) by adding the following code to the TabManagerExample_OpeningFcn.

img = imread('c:\temp\the_image.png');
image(img, 'Parent', handles.axes1);

Hi Grant,

I just want to ask how to plot a picture on an axes of a particular panel.



Unfortunately, Matlab doesn't support setting size, color etc on tabs (apart from via undocumented java calls).


Can one change the size, color and fonts on the tabs?


I have a look at your TabManager .It seems the tool that I missed that MatLab provide in order to manage the tab panels through the guide.
Thank you for sharing it with us


All working now. The problem was between chair and the keyboard. Thanks so much to Grant for helping me out on this. This is exactly what I was looking for.


Hi Amit - Are you simply running an unmodified copy of TabManagerExample in Matlab 2015a? That should work fine. I've just tested this with Matlab 2015a. Contact me (developit at and I'll see if we can sort this out.

Hi Grant - I am looking for a tool exactly like this where I can combine all my different figure into one tabbed UI.

When I try your example file it does not seems to work for me.I am getting this error:

Error using handle.handle/get
Invalid or deleted object.
Error in TabManager (line 80)
panelTag = get(hPanel,'Tag');

I tried to make my own example like you have explained here But that didnt work either.

I am using Matlab2015a. Your help is appreciated.



Tab Order of children now maintained (was reversed).
Nested tabs supported (Thanks Timon)
TabManagerExample updated to show both changes.

The background colour of a placeholder panel is now copied to its corresponding uitab.

Changed the example (TabManagerExample.m) to show how to add a SelectionChangedFcn to the tab group so that a program can be notified when a user selects a tab.

A descriptive error message is now generated if a pane representing a tab is a child of the main pane (or another "tab" pane).

Modified the tab manager example to demonstrate how to select a tab from code and added a note to the TabManager class to describe how to do this.

typo in description

Added note regarding the sorting of pane tag names prior to tab creation that can be used to control the order of tabs.

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags