How to open several GUIs one at a time in a matlab script?

1 回表示 (過去 30 日間)
Shuyuan Yu
Shuyuan Yu 2019 年 10 月 24 日
コメント済み: Shuyuan Yu 2019 年 11 月 6 日
I have 4 GUI tasks, Task A, Task B, Task C, and Task D, and would like users to complete 4 tasks one by one. If I write in the script:
Task A;
Task B;
Task C;
Task D;
then all 4 GUI tasks pop out at the same time.
How can I let Task B only pop out after the user closes Task A or is done with Task A? There are 10 problems in each task and I coded tasks to be autoamically closed after users finish 10 problems.
I want to randomize the order of 4 tasks for each participant, which means Task A could be followed by any task, therefore, I can't hard code Task A to automatically trigger Task B.
Thanks so much!
  3 件のコメント
Adam
Adam 2019 年 10 月 31 日
Or create a vector of function handles to each of your GUIs, e.g.
guis = { @TaskA, @TaskB, @TaskC, @TaskD,... };
Then you can use e.g.
doc randperm
to get a random permutation of indices into that vector and launch the relevant GUI as
guis{ idx }( )
As for the problem of all UIs opening at once, Rik's answer should sort that out.
Adam Danz
Adam Danz 2019 年 10 月 31 日
編集済み: Adam Danz 2019 年 11 月 4 日
To add to these other great solutions, you could also toggle the visibility of your GUI figures on/off as needed. That way when you're ready to move on to the next GUI, it's already generated and you just need to make it visible.

サインインしてコメントする。

採用された回答

Rik
Rik 2019 年 10 月 31 日
As long as your GUI functions return a handle to the figure, you can use the uiwait function to get the behavior you want.
  1 件のコメント
Shuyuan Yu
Shuyuan Yu 2019 年 11 月 6 日
Thanks so much for your help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by