Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

https://www.mathworks.com/matlabcentral/answers/376091-index-of-the-items-in-a-listbox

CSPM has function listbox_index

index = listbox_index( hbox )

based on the following

Code Block
listitems = {'data1', 'data2', 'vector1', 'vector2', 'vector3', 'emc'};
hfig = uifigure;
hbox = uilistbox(hfig, 'Items', listitems, 'Multiselect', 'on');
hbox.Value = {'data1', 'vector1', 'vector2', 'emc'};  %simulate user selection

%get index of selected values
[~, index] = ismember(hbox.Value, hbox.Items)

...