Create a new UIAxes for every new tab in a tab group in app designer

4 views (last 30 days)
Hi,
The code below is he code I'm using to create a new tab in a tab group when a 'New Tab' button is pushed.
function NewTab(app,src,event)
if app.tabNum < 11
app.NTcontainer = uitab(app.TabGroup2,'Title',[num2str(app.tabNum)]);
NewTabPageSetup(app)
app.tabNum = app.tabNum + 1;
else
message = sprintf('The maximum number of tabs has been reached. \nDelete a tab and try again.');
uialert(app.UIFigure,message,'Warning')
end
end
In the NewTabPageSetup function I setup all elements on the new tab page except the UIAxes as I need a new axis for each tab.
I have tried creating a new axis for each tab like this:
I know this code is wrong.
function AxisFunction(app)
AxisPosition = [281,59,531,428];
selectedTab = app.T
for i = 2:8
NewAxis(i) = uiaxes(app.NTcontainer);
NewAxis(i).Position = AxisPosition;
NewAxis(i).XGrid = "on";
NewAxis(i).YGrid = "on";
end
NTAxis = NewAxis(selectedTab)
end
function DistributionFitterTabGroupSelectionChanged(app, event)
app.T = app.DistributionFitterTabGroup.SelectedTab.Title;
AxisFunction(app)
end
I would really appreciate if someone could help or just point me in the right direction.
Andrew

Answers (1)

Kevin Holly
Kevin Holly on 18 Jul 2022
Andrew,
Please see the app attached for guidance. Let me know if you have any questions.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!