If I have already created an App, but then want to add Tabs, is it better to do this through the App Designer interface or "programmatically"? Any hints to expedite the process?

8 views (last 30 days)
That is, there is code existing already, so if I add "Tabs", how do I get my existing code into the Tab of my choice?
  1. Should I (for example...) start an entirely new App and begin with Tabs? Or
  2. Add Tabs to my existing App using the App Designer interface, and rearrange the existing App code into the tabs? Or,
  3. Add tabs _ programmatically,_ and put the new Tab code so as to encompass the existing code that I want on that Tab?
  4. Other ???

Answers (1)

TED MOSBY
TED MOSBY on 20 Aug 2025 at 8:16
Hi,
If your tabs are static (i.e., not created/destroyed dynamically based on data), the fastest approach is to use App Designer’s Component Library: drop in a Tab Group, create a few tabs, and move your existing components under the right tabs.
If you need tabs at runtime (e.g., variable number of tabs), then you can create them programmatically in startupFcn and reparent existing controls into the desired tab.
% Create a Tab Group and two tabs
app.TabGroup = uitabgroup(app.UIFigure);
t1 = uitab(app.TabGroup, 'Title','Data');
t2 = uitab(app.TabGroup, 'Title','Plots');
% Reparent existing components into tabs
app.LoadButton.Parent = t1;
app.UIAxes.Parent = t2;
Here is some documentation for reference:
Hope it helps!

Categories

Find more on Develop Apps Using App Designer 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!