'Callback',@contourbutton_Callback
(^4) To the uicontrol statement that defines the pop-up menu, add the property/value
pair
'Callback',@popup_menu_Callback
For more information, see “Write Callbacks for Apps Created Programmatically” on page
10-5.
Initialize the UI
Initialize the UI, so it is ready when the window becomes visible. Make the UI behave
properly when it is resized by changing the component and figure units to normalized.
This causes the components to resize when the UI is resized. Normalized units map the
lower-left corner of the figure window to (0,0) and the upper-right corner to (1.0,
1.0).
NoteThis code uses dot notation to set object properties. Dot notation runs in R2014b
and later. If you are using an earlier release, use the set function instead. For example,
change f.Units = 'normalized' to set(f,'Units','normalized').
Replace this code in editor:
% Make the UI visible.
f.Visible = 'on';
with this code:
% Initialize the UI.
% Change units to normalized so components resize automatically.
f.Units = 'normalized';
ha.Units = 'normalized';
hsurf.Units = 'normalized';
hmesh.Units = 'normalized';
hcontour.Units = 'normalized';
htext.Units = 'normalized';
hpopup.Units = 'normalized';
% Generate the data to plot.
peaks_data = peaks(35);
membrane_data = membrane;
[x,y] = meshgrid(-8:.5:8);
Create a Simple App Programmatically