Display GUIDE GUIs in random order?

1 view (last 30 days)
Muaaman
Muaaman on 17 Dec 2014
Commented: Davide Rambusi on 2 Mar 2018
I have 14 GUIDE GUI's and I want them to appear in a random order, one after another.
i.e. GUIDE GUI #1 opens, press push button and then the next GUIDE GUI pops up (e.g. GUIDE GUI #2) and GUIDE GUI #1 closes. The next GUIDE GUI that comes is random (one of the 13 that remain)
How may I about doing that?
Any relevant input would be greatly appreciated.

Answers (1)

Adam
Adam on 17 Dec 2014
Assuming you mean a pushbutton on some separate controlling GUI rather than on the GUI just opened, the the OpeningFcn you can define:
handles.guideGUIs{1} = @GuideGui1;
handles.guideGUIs{2} = @GuideGui2;
...
handles.guideGUIs{14} = @GuideGui14;
handles.hGUI = [];
then in the pushbutton's callback you can have something like:
delete( handles.hGUI );
r = randi( numel( handles.guideGUIs ) );
handles.hGUI = handles.guideGUIs{r}();
handles.guideGUIs(r) = [];
guidata( hObject, handles );
That is meant as a framework rather than something that will necessarily work exactly if you paste it in - I wrote it off the top of my head so haven't actually created a GUI to test it out (though I did test the function handle launching).
  5 Comments
Adam
Adam on 19 Dec 2014
The
guidata( hObject, handles )
line assumes this is all going in a GUIDE-based GUI with a pushbutton in it.
If that is the case then there shouldn't be any saving to mat files needed. The handles structure is part of the GUI, you should never load in a handles structure from file in a GUI.
If it isn't run from a GUI then you don't need guidata and probably shouldn't name the structure 'handles'.
Davide Rambusi
Davide Rambusi on 2 Mar 2018
And how to do it, if we assume the button is in the GUI just opened? Like you have a GUI that is the one where you insert basic information, then you click start and it launches the first GUI, then this just opened GUI will have a "continue" button that closes this GUI and open another one, that will have another "continue" button and so on

Sign in to comment.

Categories

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

Community Treasure Hunt

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

Start Hunting!