Let us assume that a function has been created and it takes a series of arguments (e.g., and so on). A call to this function will either produce a result (visual or numerical typically) or return data of some sort to the command-line (or command window). What is the difference between the two? Simply, the former makes the function a stand-alone list of commands that cannot be easily combined with other code. In the case of GUI's, these usually appear the appropriate entity to start off with. The exception is the case where our GUI should be used by another auxiliary application; but this case will not be considered here any further.
Let us illustrate with an example. The function draw_some_plot is is set to produce a plot and do nothing more. The code for such a file (draw_some_plot.m) may be:
This then leads us to the concept of callbacks. These are functions that will be called once an event in some GUI occurs. Once a callback has been assigned to an object, the control flow of the program will be passed to the assigned callback. If a button has been assigned the callback named do_action, then once we press that button, the code under do_action will be executed. Going back to the example above, sensible code to put under this function will be just the statement: