image thumbnail

get_yes_or_no

version 1.1.0.0 (1.78 KB) by Phillip M. Feldman
Prompt user to provide a yes-or-no answer, with an optional default value.

2K Downloads

Updated 18 Jun 2009

View License

get_yes_or_no(prompt,default) displays a prompt and reads a response from standard input. If the response is 'y', 'yes', 'Y', or "yes", a value of 1 is returned. If the response is 'n', 'no', 'N', or 'NO', a value of 0 is returned. If the user types 'quit' or 'exit', the program is stopped. If the user does not provide input and the optional default argument is present, the default value is returned. If none of these conditions is satisfied, an error message is generated and the prompt is displayed again.

Cite As

Phillip M. Feldman (2021). get_yes_or_no (https://www.mathworks.com/matlabcentral/fileexchange/24037-get_yes_or_no), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!