How to use a drop down menu to show an image based on selection.

17 ビュー (過去 30 日間)
Daniel 2022 年 11 月 5 日
コメント済み: Fazlollah 2023 年 2 月 16 日
I am trying to create an app component that shows solar radiation on the earth. the user will use a drop down menu and select a region on earth( North America, Asia....). Then I want the image to be displayed on the image app after they select a region. What is the best approach.

回答 (1 件)

Mario Malic
Mario Malic 2022 年 11 月 6 日
I would put those pictures in a cell array
images = cell(5,1);
images{1} = imread("path"); % and so on
Define ItemsData property in the DropDown component to take numeric value from 1 to n-pictures
app.DropDown.ItemsData = 1:5;
Then, you are able to use the Value, even if it's a character array, it will take the ItemsData value which you can use to index into cell array with images.
  5 件のコメント
Fazlollah 2023 年 2 月 16 日
Great Answer, thank you. you also added a private property "image".



Find more on Read, Write, and Modify Image 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!

Translated by