how to do coding on popup menu to display image

2 visualizzazioni (ultimi 30 giorni)
haha haha
haha haha il 21 Apr 2015
Risposto: Geoff Hayes il 23 Apr 2015
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?

Risposte (1)

Geoff Hayes
Geoff Hayes il 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!

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by