Code covered by the BSD License  

Highlights from
get_yes_or_no

Be the first to rate this file! 3 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)

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

| 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)
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

Contact us at files@mathworks.com