MATLAB: Get the selected value in a popup menu with a set

listmenupopupselectedvalue

Hello,
Is is possible to set the list of the popup menu (with set(handles…..)) and still get which one is selected? I did use set to have my different choices in the popup menu. But when i want to know which one is selected, it gives me the list that i had set… How can i get the selected value only?
if true
te = T(:,3); %one column of an excel file with number (101-109, 201-209,...409)
set(handles.popupname, 'String', table2array(te));
end
Thank you

Best Answer

jacques - if you want to get the selected item you would first get the index of the selected value
idx = get(handles.popupname,'Value');
Once you have the index, you can then determine which is the selected item from your list
items = get(handles.popupmenu1,'String')
selectedItem = items{idx};