How to call popup menu data in push button?

조회 수: 1 (최근 30일)
adi kul
adi kul 2016년 5월 31일
답변: Geoff Hayes 2016년 6월 2일
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
TastyPastry
TastyPastry 2016년 5월 31일
Can you take a screenshot to show what your GUI looks like

댓글을 달려면 로그인하십시오.

답변 (1개)

Geoff Hayes
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.

카테고리

Help CenterFile 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!

Translated by