how to run a callback function

5 Ansichten (letzte 30 Tage)
grapevine
grapevine am 11 Mai 2012
Hello everyone,
I can figure out the way to call a callback function from a Matlab script. I saw the syntax: function myfile(obj, event) http://www.mathworks.nl/help/techdoc/matlab_prog/f9-39541.html
but I still feel a little bit lost about the meanings of the argument obj and _event_ can you please give me some example? For example if I want to run the OpenFcn function, which is one of the callbacks listed in the block property, how can I do that?
thanks for reading

Antworten (1)

Jan
Jan am 11 Mai 2012
As explained in the documentation (read the Getting Started chapters and search for "callback"), obj is a handle of the calling object, e.g. the figure or a uicontrol. The variable event is a struct, which explains the event, which has triggered the callback. The contents of the variable depends on the type of the callback, e.g. an activated UICONTROL replies another event description as a CellSelectedCallback of a uitable.
You can set a breakpoint in the callback and inspect the contents of the event variable in the command window or the workspace browser to learn more. Because the event struct has been the empty matrix in old Matlab versions, you can get nearly all possible actions and informations just by using the object handle and its properties.

Kategorien

Mehr zu Variables finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by