User`s guide
Creating and Executing Callback Functions
8-15
vid.StartFcn = {'mycallback'};
To specify additional parameters, include them as additional elements in the cell array.
time = datestr(now,0);
vid.StartFcn = {'mycallback',time};
The first two arguments passed to the callback function are still the video input
object (obj) and the event structure (event). Additional arguments follow these two
arguments.
Using Function Handles to Specify Callback Functions
You can specify the callback function as a function handle.
For example, this code specifies the callback function mycallback as the value of the
start event callback property StartFcn for the video input object vid.
vid.StartFcn = @mycallback;
To specify additional parameters, include the function handle and the parameters as
elements in the cell array.
time = datestr(now,0);
vid.StartFcn = {@mycallback,time};
If you are executing a local callback function from within a MATLAB file, you must
specify the callback as a function handle.
Specifying a Toolbox Function as a Callback
In addition to specifying callback functions of your own creation, you can also specify the
start, stop, or trigger toolbox functions as callbacks. For example, this code sets the
value of the stop event callback to Image Acquisition Toolbox start function.
vid.StopFcn = @start;
Disabling Callbacks
If an error occurs in the execution of the callback function, the toolbox disables the
callback and displays a message similar to the following.
start(vid)
??? Error using ==> frames_cb