-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchoosedialog.m
37 lines (30 loc) · 1.16 KB
/
choosedialog.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function choice = choosedialog(vn)
d = dialog('Position',[300 300 250 150],'Name','Select Discretization');
txt = uicontrol('Parent',d,...
'Style','text',...
'Position',[20 80 210 40],...
'String','Select Discretization of Interest');
popup = uicontrol('Parent',d,...
'Style','popup',...
'Position',[75 70 100 25],...
'String',{'Choose discretization of interest'}, ...
'String',vn, ...
'Callback',@popup_callback);
btn = uicontrol('Parent',d,...
'Position',[89 20 70 25],...
'String','Close',...
'Callback','delete(gcf)');
choice = '';
% Wait for d to close before running to completion
uiwait(d);
function popup_callback(popup,event)
idx = popup.Value;
popup_items = popup.String;
% This code uses dot notation to get properties.
% Dot notation runs in R2014b and later.
% For R2014a and earlier:
% idx = get(popup,'Value');
% popup_items = get(popup,'String');
choice = char(popup_items(idx,:));
end
end