Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How can I implement a dialog GUI in MATLAB?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (3개)
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.
댓글 수: 0
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
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
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!