Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
How can I implement a dialog GUI in MATLAB?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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?
0 Kommentare
Antworten (3)
Paulo Silva
am 2 Mär. 2011
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.
0 Kommentare
Matt Fig
am 2 Mär. 2011
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 Kommentare
Walter Roberson
am 2 Mär. 2011
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
am 2 Mär. 2011
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...
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!