Programming |
Specifying the Value of Callback Function Properties
You associate a callback function with a specific event by setting the value of the appropriate callback property. You can specify the callback function as a text string, cell array, or function handle. To access the object and event arguments, you must specify the function as a cell array or as a function handle. If your callback function accepts additional arguments, you must use a cell array.
The following table shows the syntax for several sample callback functions and describes how you call them.
This example illustrates several ways you can specify the value of timer object callback function properties, some with arguments and some without. To see the code of the callback function, my_callback_fcn
, see Example: Writing a Callback Function.
StartFcn
callback. Note that the example specifies the value in a cell array because the callback function needs to access arguments passed to it.
StopFcn
callback. The example specifies the callback function by its handle, rather than as a text string. Again, the value is specified in a cell array because the callback function needs to access the arguments passed to it.
TimerFcn
callback. The example specifies the MATLAB commands in a text string.
Creating Callback Functions | Timer Object Execution Modes |
© 1994-2005 The MathWorks, Inc.