User`s guide

3 How to Create a Simple GUI Programmatically
end
The next topic, “Program the Push Buttons” on page 3-12, shows you how to
write callbacks for the three push buttons.
Program the Push Buttons
Each of the three push buttons creates a different type of plot using the
data specified by the current selection in the pop-up menu. The push button
callbacks plot the data in
current_data. They automatically have access to
current_data because they are nested at a lower level.
Add the following callback s to your file following t he pop-up m en u callback
and before the final
end statement.
% Push button callbacks. Each callback plots curr ent_data in the
% specified plot type.
function sur fbut ton_Callback(source,eve ntdata)
% Display surf plot of the currently selec ted data.
surf(current_data);
end
function mes hbut ton_Callback(source,eve ntdata)
% Display mesh plot of the currently selec ted data.
mesh(current_data);
end
function con tour button_Callback(source, eventdata)
% Display contour plot of the currently se lected data.
contour(current_data);
end
The next topic shows you how to associate each callback with its specific
component.
Program Callbacks for the Simple GUI Components
When the GUI user selects a data set from the pop-up menu or clicks one o f
the push buttons, MATLAB software executes the callback associated with
3-12