Clear Filters
Clear Filters

How to plot new results only in tab that is being viewed by user - App Designer

2 views (last 30 days)
Within my app I am attempting to have the simulation results be plotted in a new plot that is within a new tab. I have been succesful in generating a new tab and plot within that tab. I have also been succesful in getting the results to plot in that new plot/tab. However, I have not been able to realize the functionality that I set out to do.
Specifically I want to be able to plot the results in the figure within the tab that is be looked at by the user. If the lamp is green it will overwrite the plot on the tab that is being looked at when I press 'Execute' (and not create a new tab/plot or plot on a tab/plot that is not being viewed). If the lamp is red then they are generating a new result plot in a new tab when 'Execute' is pressed. How can this be done?
I am looking to generate these plots in such a way that I can have access to them (i.e. thier handles) later to be saved and exported.
Other information that might be useful is that the 'TabGroup' is within a panel and the way that I am getting coding alerts with how I am executing my plot creation and then using the object. The error is "Specify a UIAxes handle as first argument". This error does not seem to seem to interupt my app functionality, but may be a source of my diffculties.
Here is the code for the beginning of Execute button in MATLAB App Designer followed by a screen shot of the section of the app. Any tips or suggestions will be greatly appreciated.
function ExecuteButtonPushed(app, event)
% Start Clock
tic;
% Plot Results on New Tab
NewOutput = app.Lamp_5.Color;
if NewOutput == [1.00,0.00,0.00]
tab = uitab(app.TabGroup2,"Title",['Result ' num2str((length(app.TabGroup2.Children))+1)]);
app.TabGroup2.SelectedTab = tab;
NewPlot = uiaxes(tab);
title(NewPlot, 'Spectra')
xlabel(NewPlot, 'Wavelength (um)')
ylabel(NewPlot, 'Amplitude')
NewPlot.FontName = 'Garamond';
NewPlot.FontSize = 14;
NewPlot.FontWeight = 'bold';
NewPlot.ColorOrder = [0 0.4471 0.7412;0.851 0.3294 0.102;0.9294 0.6941 0.1255;0.4941 0.1843 0.5569;0.4667 0.6745 0.1882;0.302 0.7451 0.9333;0.6353 0.0784 0.1843];
NewPlot.XGrid = 'on';
NewPlot.YGrid = 'on';
NewPlot.Position = [0 1 554 395];
CurrentPlot = NewPlot;
end
if NewOutput == [0.00,1.00,0.00]
CurrentPlot = app.UIAxes_2;
end

Answers (0)

Categories

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

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!