You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
EVENTHANDLER allows a user to have one or more callback functions executed when an event of interest happens. Specifically, it can track the following events:
* Creation and deletion of variables, figures, and axes
* Deletion of generic graphics objects
* Changes in value of variables
* Changes in value of object parameters (including figures, axes, and any other graphics object having a handle), as well as sets of object parameters
A (clearly non-exhaustive) list of examples might include listeners that fire when:
* a figure is moved (or resized, but that already exists)
* an object is added/removed to a set of axes
* the text in a title/label/legend is changed
* a variable is cleared from memory
* etc.
In addition to calling functions when these events occur, event related information is retained (e.g. previous values, the name of the changed variable, etc.) and can be passed to the callback function.
Event listeners take wildcards as well as specific values, as well as exclusion lists (e.g. "fire this event when a variable is created that starts with the letter 'q' or contains an underscore, but only so long as it does not contain the letter 'u' or end with a digit").
Note: This function is not a true event handler (obviously, since that would require editing the underlying Matlab program). Rather, it involves a watching routine operating in the background. For this reason, it is not applicable to hardcore numerical programming where things change on the order of fractions of milliseconds. It is intended to be used with GUI's where human interaction requires at least fractions of seconds between events.
While I have tested this out reasonably thoroughly, I find that these kinds of functions often have weird bugs that only show up in unusual circumstances. Bug reports, suggestions for changes, as well as any other feedback would be greatly appreciated.
Cite As
Jeff Dunne (2026). Incorporating events in Matlab (https://se.mathworks.com/matlabcentral/fileexchange/12609-incorporating-events-in-matlab), MATLAB Central File Exchange. Retrieved .
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and MATLAB Answers
General Information
- Version 1.0.0.0 (10.7 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0.0 |
