MATLAB: Getting value from a listbox. Error: Cell contents reference from a non-cell array object.

cell-array objectgetlistbox

Im trying to get the value selected in a listbox(Temp_listbox) by a callback botton and the listbox contains cells of integers:
string5 = get(handles.Temp_listbox, 'String');%%get cond1
value5 = get(handles.Temp_listbox, 'Value');
cond1 = string5{value5};
But I got the error: Cell contents reference from a non-cell array object.
Any idea about how could be solved? Thanks in advance.
Note: The value of cond1 is used afterwards to find the intersection in an array and plot the data.

Best Answer

I suppose that your listbox contains only one string. Compare two codes:
1:
lb = uicontrol('Style','listbox','Position',[10 10 100 100],'String','a');
a = get(lb,'String');
a{get(lb,'Value')}
2:
lb = uicontrol('Style','listbox','Position',[10 10 100 100],'String',{'a','b','c'});
a = get(lb,'String');
a{get(lb,'Value')}
Code 1 produces an error.