How to call popup menu data in push button?

3 ビュー (過去 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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by