Create n number of figures in MATLAB GUI.

2 views (last 30 days)
In normal matlab coding, we can have as many plots as we want. For eg:
plot(x,sinx);
figure;
plot(x,sinx);
and so on
Now I want to develop a GUI. I different sets of temperature values against time. So I want show one set of temperature values against time as the figure1. Then create a new figure by pressing a push button and then show another set of temperature values against time and so on upto n figures. I am average level matlab programmer but creating gui in matlab, I am learning it for the first time today. So far what I know is place an axes on the GUI background and then use that axes to plot the graph. I want to create another figure by pressing some button in the GUI. Is that possible or I have to just show the next set of temperature readings in the same figure itself without forming a seperate figure. Which is possible. Kindly help me understand how to do it, if it is possible to do it. Thanking You.

Answers (1)

Jan
Jan on 16 Jan 2019
The easiest way is not to use GUIDE or the AppDesigner, but to create the figures programmatically. See FEX: 41 GUI examples, for many example codes.
function YourTool(Param)
if nargin == 0
Param = 1;
end
FigH = figure;
axesH = axes;
title(sprintf('Figure for Param: %d', Param));
plot(axesH, 1:10, rand(10,10))
uicontrol('Style', 'PushButton', 'Position', [5, 5, 100, 26], ...
'String', 'Next plot...', ...
'Callback', {@myCallback, Param});
end
function myCallback(ButtonH, EventData, Param)
% The easiest way is to call the main function again:
Param = Param + 1;
YourTool(Param);
end

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products


Release

R2014a

Community Treasure Hunt

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

Start Hunting!