how to do coding on popup menu to display image

1 view (last 30 days)
I have design a GUI, i have about maybe 10 image name to select in the popup menu what code should i use so that the image i select at the popup menu will be call out?

Answers (1)

Geoff Hayes
Geoff Hayes on 23 Apr 2015
haha - you will need to access the String and Value properties of the popup menu to get the image name that has been selected. Your popup menu callback would looks something like
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% get the cell array of strings
popUpData = get(hObject,'String');
% get the index of the current selection
popUpIndex = get(hObject,'Value');
% write out the selection name
fprintf('%s\n',popUpData{popUpIndex});
Try the above and see what happens!

Categories

Find more on Migrate GUIDE Apps 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!