Create uitab with different name (several uitabs)

2 views (last 30 days)
Actually I have two questions about uitabs 1. Is "is there any problem using uitab in matlab R2014a other then the warning and documentation?" 2. Is " I want to creat a uitab group with several and different uitabs, these uitabs contain different gui components, each uitab is generated when clicking a push button so the user clicks once if he needs one uitab and twice if he needs two and so on, the general code that I use is to gather all gui components in handles structure like
Handles.fig=figure
Handles.Uitbgrp=uitabgroup('parent',handles.fig,position,...)
Handles.pb1=uicontrol(parent...,'callback',@pb1) % pushbutton
.
.
.
N=0;
Function pb1(source,event)
N=N+1
Handles.myTab1=uitab('parent',handles.uitbgrp,....)
I want that the value of handles.myTab1 changes to handles.myTabN each time the push button is triggered so I can manipulate my data easily and clearly in accordance with the overall structure of the program

Accepted Answer

Charles
Charles on 29 May 2015
Instead of changing a number within the name of the tab, simply make an array of tabs. In your example (after fixing a lot of capitalization issues), I come up with teh following:
function test
Handles.fig=figure;
Handles.Uitbgrp=uitabgroup('parent',Handles.fig);
Handles.pb1=uicontrol('parent',Handles.fig,'callback',@pb1) % pushbutton
N=0;
function pb1(source,event)
N=N+1;
Handles.myTab(N)=uitab('parent',Handles.Uitbgrp);
end
end
This code creates an array of tab objects as Handles.myTab(), numbered sequentially. Much better than unique alpha names, as now you can programatically reach each object. I did not embellish at all, you will need to add tab titles, button name, etc. etc.
Chuck
  1 Comment
Zine
Zine on 5 Jun 2015
Thanks very much, it works very well, also my uicontrols I used them as arrays, thanks

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!