A Callback is a request for performing a certain task or action.
When you have a button on your figure, you must tell Matlab what it should do when that button is pressed. This is done through callbacks. Callbacks are nothing else but functions that get executed when you do something. Note that this “something” can be
Note that this is the epitome of “object-oriented programming”!
You see that there are many such callbacks - and in general you just don’t want to deal with them. To make is simpler for you to nevertheless make simple graphical applications, Matlab provides the program GUIDE.
When you are drawing things in Matlab, you need to have some way to control the looks of your Window (e.g. the Backgroundcolor, if a Menu is shown, etc.), the thickness of the Lines you draw, the font of your Text labels, etc. The way this is commonly done in Matlab (and also in other graphical environments) is through “Handles”.
Organization of Handles in a simple figure.
For example, the figure handle controls parameters like the
The following commands are helpful for working with the figure handle:
Note that most of these commands are not specific for the figure handle. For example, you can also use the command findobj to find a line handle. Note that you can have as many figures as you want. The current figure is the one on which you draw when you type for example plot(1:10).
Similarly, the command gca provides the handle for the current axis. Note that there is a hierarchy: Each figure can have many axes, and each axis belongs to exactly one figure. Each axis can have many lines, and many text objects.
For example, the command
lineHandle = plot([0 1 2 3 4], [0 1 4 9 16]) LineHandle_Elements = get(lineHandle);
produces a structure with the following elements
Elements of a Matlab line-handle. Important fields are marked. Note that no “Tag” (i.e. a name that can be used to identify the handle) has been given yet, and that the field “User Data” (which can store any element you want it to) is still empty.
If you want to modify any of these elements you can do so with the set command:
set(lineHandle, ‘LineWidth’, 2, … ‘Color’, [1 0 0]);
draws a thick, red line.
Try to make your printouts such that when you look at the printout in one year from now, you will still know what is shown there.
Graphs should always contain enough information to be understood on their own, without any external additional information.