Using the selected string of listdlg not the index number
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I'm currently trying to find a way to use the string selected when using listdlg, not the index number it provides through the selection output.
So for example:
I somebody selects 'cat,' which is the third option in the list - instead of just getting the value 3, is there anyway to have it output the 'string' cat?
I am wanting the output of that selection to be used in a function, so just having the index value doesn't help.
Does anybody know a way to do this?
0 commentaires
Réponses (1)
Guillaume
le 17 Mar 2017
Well, since you obviously have the ListString you passed to listdlg in the first place, just use the returned index to retrieve the selected value(s) from that list:
somelist = {'cat', 'dog', 'fish'};
[selectionindex, ok] = listdlg('ListString', somelist);
if ok
selectedvalues = somelist(selectionindex);
%do something with selectedvalues
end
0 commentaires
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!