フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I implement a dialog GUI in MATLAB?

1 回表示 (過去 30 日間)
buxZED
buxZED 2011 年 3 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
task_complete=0;
while task_complete==0
disp(' ')
disp('1:Q1')
disp('2:Q2')
P_Switch = input ('Enter Question Number:');
switch P_Switch
case 1
clear
disp('solve Q1')
P1
case 2
clear
disp('solve Q2')
P2
end
disp(' ')
task_complete=input(' Correct Solution? yes=1, no=0:');
end
Can I get this to be a dialog box with eye candy buttons instead of text?

回答 (3 件)

Paulo Silva
Paulo Silva 2011 年 3 月 2 日
Yes you can, how?
1-create a figure
2-create two buttons
3-create text box for the questions and info
4-create edit box for the input
5-add your code
Using GUIDE that's super easy, doing it without GUIDE is only a little harder.

Walter Roberson
Walter Roberson 2011 年 3 月 2 日
See questdlg()

Matt Fig
Matt Fig 2011 年 3 月 2 日
Something like this:
task_complete='No';
while strcmp(task_complete,'No')
C = questdlg('Choose question to solve:', ...
'Select a question', ...
'1','2','1');
switch C
case '1'
P1
case '2'
P2
end
task_complete = questdlg('Are we done?', ...
'Finished?', ...
'Yes','No','Yes');
end
  2 件のコメント
Walter Roberson
Walter Roberson 2011 年 3 月 2 日
Matt's solution closely follows the logic of the original question. Neither the original question nor Matt's solution will explicitly recognize that some other value than 1 or 2 has been chosen, a chase that _probably_ should not ask the 'Done' question but should instead go back to asking the question again.
The way to recognize other data as having been entered is to use a default section in the switch statement.
(Specifically, if the user clicks on the Close button or on the Cancel button, the result of questdlg() will be the empty string. The default value that Matt provided, the '1', is used only if the user presses Return.)
Matt Fig
Matt Fig 2011 年 3 月 2 日
Yes, I recognized that too. It will be up to buxZED to define the behavior of the program in case the user opts out at the dlg. Does it quit? Does it keep pestering with a dialog? Only buxZED knows...

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by