[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Printing a value from index array
From: |
Przemek Klosowski |
Subject: |
Re: Printing a value from index array |
Date: |
Tue, 24 Jul 2018 12:03:49 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 |
On 07/23/2018 11:07 AM, harish3679 wrote:
Hi,
for this experiment
choice = menu("beverages"{"beer","whiskey","brandy","vodka"});
disp(choice);
it asks me to select a number
menu
[1] beer
[2] whiskey
[3] brandy
[4] vodka
when I enter a number it just displays the number and excludes the strings
like beer, whiskey. .
Can I use listdlg instead?
Yes, but listdlg() is not yet widely available--for instance, the latest
Fedora version is 4.2.2 and it still doesn't have it.
As you indicated, menu() returns simply the menu sequence number---you
have to keep track of the item yourself:
itemlist = {"Neutron", "Electron", "Quark", "Proton", "Neutrino"};
octave:10> menu('particle',itemlist)
particle
[ 1] Neutron
[ 2] Electron
[ 3] Quark
[ 4] Proton
[ 5] Neutrino
Select a number: 3
ans = 3
octave:11> disp(itemlist{3})
Quark