TXTMENU can be used to generate a text-menu of choices for user input in the Matlab command window. The function mimics the behavior of the MENU command from older Matlab versions, which did not yet provide support for graphical user-interfaces. Compared to the current version of the MENU command, TXTMENU differs in that it will always use the command-window regardless of the graphical capabilities of the workstation.
CHOICE = txtmenu(HEADER, ITEM1, ITEM2, ... )
displays the HEADER string followed in sequence by the menu-item strings: ITEM1, ITEM2, ..., ITEMn. The number of the selected menu-item will be returned into the scalar variable CHOICE. There is no upper limit to the total number of menu items.
CHOICE = txtmenu(HEADER, ITEMLIST)
where ITEMLIST is a string cell array is also a valid syntax.
K = txtmenu('Choose a color','Red','Blue','Green')
will display:
Choose a color: 1) Red 2) Blue 3) Green Select a menu number:
on the screen. The number entered by the user in response to the prompt is returned to the variable K (e.g. K = 2 implies that the user selected Blue from this example menu).