Skip to content

menu

miscellaneous · scripts/miscellaneous/menu.m

: choice = menu (title, opt1, …, optn)
: choice = menu (title, {opt1, …, optn})

Show a numbered list of options in the command window and wait until the user types the number of one of them. The result choice is that number.

title is a string (it may be empty) printed above the list. The options are strings, given as separate arguments or as one cell array of strings. An entry that is not a whole number between 1 and the number of options is refused and the question is asked again.