Need a bit help with getting values from gui listbox

1 Ansicht (letzte 30 Tage)
Kokalz
Kokalz am 25 Jul. 2012
Hi guys!
I have a gui witha listbox with 3 values in it (0.01, 0.1 & 1).I need my gui to use numerical value selected in the listbox but I am having a bit of a trouble with it. I tried the following:
timeStep = get(str2double(handles.listBox, 'String'));
but matlab gives me the following error:
Error using str2num
Too many input arguments.
I might be wrong, but it seems like it tries taking all 3 of the string values instead of the selected one. Any idea how to fix this??
Thank you !
  1 Kommentar
Jan
Jan am 25 Jul. 2012
The error message contains "str2num", but the code "str2double"?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan
Jan am 25 Jul. 2012
Bearbeitet: Jan am 25 Jul. 2012
The other way around: Get the string at first and convert it to doubles afterwards:
str2double(get(handles.listBox, 'String'))

Weitere Antworten (1)

Kokalz
Kokalz am 25 Jul. 2012
It still takes all 3 values from the listBox. How can I make it take onl the selected one?

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by