I was wondering if someone could tell me how to make a simple "start program button?" prompt where the program will only continue if the user hits "ok." If they hit "no," then the program just exits.This will got at the start of the program.

 채택된 답변

Geoff Hayes
Geoff Hayes 2014년 6월 24일
편집: Geoff Hayes 2014년 6월 24일

0 개 추천

Check out the following link http://www.mathworks.com/help/matlab/ref/questdlg.html. You can use a question dialog to query the user if he/she wishes to start the program or not. Based on that result, the program will continue (or not).

댓글 수: 5

Michael
Michael 2014년 6월 24일
Thanks for the response Geoff, is there anyway just to make 2 options?
just put in 2 options, they just show 3 as an example.
choice = questdlg('Would you like a dessert?', ...
'Dessert Menu', ...
'Ice cream','Cake','Cake');
Michael - yes, you can create a question dialog with just two options/choices. The format for the code would be
button = questdlg('qstring','title','str1','str2',default)
Where qstring is your question string (for the user), title is the title for the dialog, str1 is the first button option, str2 is the second button option, and default is the button that you want focus for.
In your case, you could have something like
button = questdlg('Start program?','Prompting user..','Yes','No','Yes');
Try it out and see what happens!
Michael
Michael 2014년 6월 24일
Got it to work. Thanks for the help!
Geoff Hayes
Geoff Hayes 2014년 6월 25일
Awesome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Performance and Memory에 대해 자세히 알아보기

질문:

2014년 6월 24일

댓글:

2014년 6월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by