Value of Pop-up Menu
Ältere Kommentare anzeigen
I want to get value as a number from pop-menu. for example if user want to select gender. 1 for male and 2 for female. i have create this code
function gender_Callback(hObject, eventdata, handles)
gender = (get(hObject, 'Value'));
switch gender
case 'Male'
gender = 1;
case 'Female'
gender = 2;
end
% Save the new n value
handles.gender = gender;
guidata(hObject,handles)
and this for get value
gender = handles.gender;
but it's result not 1 or 2, but strange number (e.g 212.0060). what's wrong and how the correct code. thank you very much
Akzeptierte Antwort
Weitere Antworten (1)
Azzi Abdelmalek
am 13 Mai 2013
The code should be
gender = (get(hObject, 'Value'));
switch gender
case 1
%do
case 2
%do
end
1 Kommentar
Retno
am 13 Mai 2013
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!