Need a bit help with getting values from gui listbox

조회 수: 1 (최근 30일)
Kokalz
Kokalz 2012년 7월 25일
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
Jan
Jan 2012년 7월 25일
The error message contains "str2num", but the code "str2double"?

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2012년 7월 25일
편집: Jan 2012년 7월 25일
The other way around: Get the string at first and convert it to doubles afterwards:
str2double(get(handles.listBox, 'String'))

추가 답변 (1개)

Kokalz
Kokalz 2012년 7월 25일
It still takes all 3 values from the listBox. How can I make it take onl the selected one?

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by