How to call popup menu data in push button?
1 次查看(过去 30 天)
显示 更早的评论
Hello, With the help of popup menu I am getting data from the user as follows:
selection = get(hObject, 'Value');
switch selection
case 1
h=msgbox('Please select the Surface');
case 2
surface2=0;
case 3
surface2=1;
prompt = {'Enter the radius (mm)','Enter the x ','Enter the y '};
dlg_title = 'Sphere';
num_lines = 1;
defaultans = {'','0','0'};
answer = inputdlg(prompt,dlg_title,num_lines,defaultans);
r_sphere=str2num(answer{1});
x0=str2num(answer{2});
y0=str2num(answer{3});
From above I get some specific inputs from users. Now I need to use them in later part of the code. I have a push button where I calculate things and there remains my remaining code. Now what is my problem is I am not able to call back the popup menu inputs to run the code in pushbutton. Can anyone suggest a way to get values of popup into push button?
回答(1 个)
Geoff Hayes
2016-6-2
adi - I am assuming that you are using GUIDE to create your GUI (given the hObject reference in the above code). If that is the case, then you can use the handles structure to reference the popupmenu control from within the pushbutton callback. For example,
function pushbutton1_Callback(hObject, eventdata, handles)
selectedItemIndex = get(handles.popupmenu1,'Value');
% etc.
The above will allow you to access the index of the selected item of the popup menu from within the pushbutton callback.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!