User`s guide
Creating and Executing Callback Functions
Using a Text String to Specify Callback Functions
You can specify the callback function as a string. For example, this code
specif ies the callback function
mycallback as the value of the start event
callback property
StartFcn for the video input object vid.
vid.StartFcn = 'mycal lback';
In th is case, t h e callb ack is eval ua ted in the MATLAB wo rk s pa ce.
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.
vid.StartFcn = {'myca llback'};
To specify additional parameters, include them as additional elements in
the cell array.
time = datestr(now,0) ;
vid.StartFcn = {'mycal lback',time};
Thefirsttwoargumentspassedtothecallback function are still the video
inputobject(
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 = @mycal lback;
To spec
ify additional parameters, include the function handle and the
parame
ters as elements in the cell array.
time = datestr(now,0) ;
vid.StartFcn = {@mycal lback,time};
7-15