Display list of values using drop down list
Show older comments
Hi, I want to create a drop down list and the corresponding value (example some variables) has to be displayed when selected. How can this be achieved. Appreciate your support!
For Example, I would like to create a drop down list similar to it

Accepted Answer
More Answers (1)
Adam
on 3 May 2017
doc uicontrol
gives examples, including a 'popup' menu which is what you want.
5 Comments
pradeep kumar
on 3 May 2017
Adam
on 3 May 2017
Well, it depends how you have stored the data. I would probably use
doc containers.Map
as e.g.
temperatureMap = containers.Map( { 'Delhi', 'Bangalore', 'Chennai', 'Hyderabad' }, [ 20, 25, 24, 22 ] );
Then in the callback of your popup menu you can get the string as e.g.
city = hPopup.Sting( hPopup.Value );
and access temperature as
temperatureMap( city )
which you can then put into a text control.
pradeep kumar
on 3 May 2017
Adam
on 3 May 2017
As I said in my original answer:
doc uicontrol
There are examples there.
pradeep kumar
on 5 May 2017
Categories
Find more on Mapping Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!