Model, Block, and Port Callbacks
Callbacks are a powerful way to customize the behavior of a Simulink® model. Use callbacks to execute MATLAB® code in response to specific actions, such as opening a model or stopping a simulation. Each callback corresponds to a specific action. You specify the MATLAB code that a callback executes. When the corresponding action occurs, Simulink executes the callback code.
For example, the code that you specify for the
PreLoadFcn model callback executes before the model
loads. You can provide code for
PreLoadFcn that loads the
variables the model uses into the MATLAB workspace.
|Create and specify properties of text, image, and area annotations|
|Get annotation executing callback|
|Callback Button||Execute MATLAB code using button|
- Customize Model Behavior with Callbacks
Use callbacks to customize the behavior of a Simulink model.
- Model Callbacks
Specify MATLAB code that executes at certain action points for models, for example, after the model loads or when you save it.
- Block Callbacks
Set block callbacks that execute when blocks are loaded, opened, or edited.
- Initialization Function
Execute or evaluate an initialization function at the beginning of model compilation.
- Port Callbacks
Set callbacks on input and output ports that execute every time the connectivity of these ports changes.
- View and Trace Callbacks in Models
View and trace all the callbacks executed in a model.