| Simulink Reference | ![]() |
Register a listener for a block method execution event.
Syntax
Description
h = add_exec_event_listener(blk, event, listener) registers a listener for a block method execution event where the listener is an M-file program that performs some task, such as logging runtime data for a block, when the event occurs (see "Listening for Method Execution Events" for more information). Simulink invokes the registered listener whenever the specified event occurs during simulation of the model.
| Note Simulink can register a listener only while a simulation is running. Invoking this function when no simulation is running results in an error message. To ensure that a listener catches all relevant events triggered by a model's simulation, you should register the listener in the model's StartFcn callback function (see Model Callback Functions). |
Arguments
Specifies the block whose method execution event the listener is intended to handle. May be one of the following:
Specifies the type of event for which the listener listens. It may be any of the following:
Specifies the listener to be registered. It may be either a string specifying a MATLAB expression, e.g., 'disp(''here'')' or a handle to a MATLAB function that accepts two arguments. The first argument is the block runtime object of the block that triggered the event. The second argument is an instance of EventData class that specifies the runtime object and the name of the event that just occurred.
Return Value
add_exec_event_listener returns a handle to the listener that it registered. To stop listening for an event, use the MATLAB clear command to clear the listener handle from the workspace in which the listener was registered.
| Simulation Commands | model | ![]() |
© 1994-2005 The MathWorks, Inc.