Incorporating events in Matlab

Function to fire callbacks on variable and object changes/creations/deletions

現在この提出コンテンツをフォロー中です。

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.

引用

Jeff Dunne (2026). Incorporating events in Matlab (https://jp.mathworks.com/matlabcentral/fileexchange/12609-incorporating-events-in-matlab), MATLAB Central File Exchange. に取得済み.

カテゴリ

Help Center および MATLAB AnswersCreating, Deleting, and Querying Graphics Objects についてさらに検索

一般的な情報

MATLAB リリースの互換性

  • すべてのリリースと互換性あり

プラットフォームの互換性

  • Windows
  • macOS
  • Linux
バージョン 公開済み リリース ノート Action
1.0.0.0