
Programming the GUI
3-15
end
The next topic, “Programming the Push Buttons” on page 3-15, shows you how
to write callbacks for the three push buttons.
Programming 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 callbacks to your file following the pop-up menu callback and
before the final
end statement.
% Push button callbacks. Each callback plots current_data in the
% specified plot type.
function surfbutton_Callback(source,eventdata)
% Display surf plot of the currently selected data.
surf(current_data);
end
function meshbutton_Callback(source,eventdata)
% Display mesh plot of the currently selected data.
mesh(current_data);
end
function contourbutton_Callback(source,eventdata)
% Display contour plot of the currently selected data.
contour(current_data);
end
The next topic shows you how to associate each of the callbacks you’ve created
with its specific component.
Associating Callbacks with Their Components
When the GUI user selects a data set from the pop-up menu or clicks one of the
push buttons, MATLAB executes the callback associated with that particular
event. But how does MATLAB know which callback to execute? You must use
Komentáře k této Příručce