Be the first to rate this file! 106 downloads (last 30 days) File Size: 1.78 KB File ID: #24037

get_yes_or_no

by Phillip M. Feldman

 

08 May 2009 (Updated 18 Jun 2009)

Code covered by BSD License  

Prompt user to provide a yes-or-no answer, with an optional default value.

Download Now | Watch this File

File Information
Description

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.

MATLAB release MATLAB 7.8 (R2009a)
Zip File Content  
Other Files get_yes_or_no.m,
license.txt
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
18 Jun 2009

Version 2.1 implements workaround for Matlab compiler bug involving strtrim. (strtrim dies when the input string is empty).

Tag Activity for this File
Tag Applied By Date/Time
input Phillip M. Feldman 08 May 2009 10:12:08
yesorno Phillip M. Feldman 08 May 2009 10:12:08
binary Phillip M. Feldman 08 May 2009 10:12:08
choice Phillip M. Feldman 08 May 2009 10:12:08
boolean Phillip M. Feldman 08 May 2009 10:12:08
io Phillip M. Feldman 08 May 2009 10:12:08
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com