User`s guide
8 Using Events and Callbacks
8-14
t = fix(abstime);
sprintf('%s %d:%d:%d','timestamp', t(4),t(5),t(6))
To see how this function can be used as a callback, see “Viewing a Sample Frame” on
page 8-16.
Specifying Callback Functions
You associate a callback function with a specific event by setting the value of the event's
callback property. The video input object supports callback properties for all types of
events.
You can specify the callback function as the value of the property in any of three ways:
• Text string
• Cell array
• Function handle
The following sections provide more information about each of these options.
Note To access the object or event structure passed to the callback function, you must
specify the function as a cell array or as a function handle.
Using a Text String to Specify Callback Functions
You can specify the callback function as a string. 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';
In this case, the callback is evaluated in the MATLAB workspace.
Using a Cell Array to Specify Callback Functions
You can specify the callback function as a text string inside a cell array.
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.