Display list of values using drop down list

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

 採用された回答

Image Analyst
Image Analyst 2017 年 5 月 5 日

1 投票

Use GUIDE to place a popup control on the GUI figure. Then double click it and edit the 'String' property. http://blogs.mathworks.com/videos/category/gui-or-guide/
Programmatically you can change what appears by setting the string property of the popup control:
strings = {'Select a city', 'Honolulu', 'San Diego', 'Scottsdale', 'Hong Kong');
handles.popup1.Strings = strings;

1 件のコメント

pradeep kumar
pradeep kumar 2017 年 5 月 8 日
Thanks 'Image Analyst' for the answer.

サインインしてコメントする。

その他の回答 (1 件)

Adam
Adam 2017 年 5 月 3 日

0 投票

doc uicontrol
gives examples, including a 'popup' menu which is what you want.

5 件のコメント

pradeep kumar
pradeep kumar 2017 年 5 月 3 日
Hi, I have provided an image reference for what I am expecting
Adam
Adam 2017 年 5 月 3 日
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
pradeep kumar 2017 年 5 月 3 日
Thanks Adam for the answer. Can I achieve this in simulation that is during runtime? i.e. in a dialog box. If yes, how to create such buttons in matlab which can work similar to drop down list.
Adam
Adam 2017 年 5 月 3 日
As I said in my original answer:
doc uicontrol
There are examples there.
pradeep kumar
pradeep kumar 2017 年 5 月 5 日
thank you Adam.. I will refer them.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by