Skip to Main Content Skip to Search
Product Documentation

add_exec_event_listener - Register listener for block method execution event

Syntax

h = add_exec_event_listener(blk, event, listener);

Description

h = add_exec_event_listener(blk, event, listener) registers a listener for a block method execution event where the listener is a MATLAB program that performs some task, such as logging runtime data for a block, when the event occurs (see Listening for Method Execution Events in Simulink User's Guide for more information). Simulink software invokes the registered listener whenever the specified event occurs during simulation of the model.

Input Arguments

blk

Specifies the block whose method execution event the listener is intended to handle. May be one of the following:

event

Specifies the type of event for which the listener listens. It may be any of the following:

Event

Occurs...

'PreDerivatives'

Before a block's Derivatives method executes

'PostDerivatives'

After a block's Derivatives method executes

'PreOutputs'

Before a block's Outputs method executes.

'PostOutputs'

After a block's Outputs method executes

'PreUpdate'

Before a block's Update method executes

'PostUpdate'

After a block's Update method executes

listener

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.

Output Arguments

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.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS