| Using Simulink | ![]() |
Accessing Block Data During Simulation
Simulink provides an application programming interface, called the block runtime interface, that enables programmatic access to block data, such as block inputs and outputs, parameters, states, and work vectors, while a simulation is running. You can use this interface to access block runtime data from the MATLAB command line, the Simulink Debugger, and from Level-2 M-file S-functions (see Writing S-Functions in M ).
| Note You can use this interface even when the model is paused or is running or paused in the debugger. |
About Block Runtime Objects
The block runtime interface consists of a set of Simulink data object classes (see Working with Data Objects) whose instances provide data about the blocks in a running model. In particular, the interface associates an instance of Simulink.RunTimeBlock, called the block's runtime object, with each block in the running model. A runtime object's methods and properties provide access to runtime data about the block's I/O ports, parameters, sample times, and states.
Accessing a Runtime Object
Every block has a RuntimeObject parameter whose value, while a simulation is running, is a handle for the blocks' runtime object. This allows you to use get_param to obtain a block's runtime object. For example, the following statement
returns the runtime object of the currently selected block.
Listening for Method Execution Events
One application for the block runtime API is to collect diagnostic data at key points during simulation, such as the value of block states before or after blocks compute their outputs or derivatives. The block runtime API provides an event-listener mechanism that facilititates such applications. For more information, see the documention for the add_exec_event_listener command. For an example of using method execution events, enter
| Browsing Block Libraries | Working with Signals | ![]() |
© 1994-2005 The MathWorks, Inc.