Main Content

Simulink Debugger Programmatic Interface

Controlling the Debugger

When you run the Simulink® debugger programmatically, you control the debugger by entering commands at the debugger command line in the MATLAB® Command Window. You must start the debugger programmatically using the sldebug function and not using the Simulink Toolstrip. The debugger accepts abbreviations for debugger commands.

Note

You can repeat some commands by entering an empty command (by pressing the Enter key).

Method ID

Some of the Simulink debugger commands and messages use method IDs to refer to methods. A method ID is an integer assigned to a method the first time the method is invoked. The debugger assigns method IDs sequentially, starting with 0.

Block ID

Some of the debugger commands and messages use block IDs to refer to blocks. Block IDs are assigned to blocks while generating the sorted lists for the model during the compilation phase of the simulation. A block ID has the form sysIdx:blkIdx, where sysIdx is an integer that identifies the system that contains the block and blkIdx is the position of the block in the sorted list for the system. For example, the block ID 0:1 refers to the first block in the root system of a model. The slist function shows the block ID for each debugged block in the model.

Accessing the MATLAB Workspace

You can enter any MATLAB expression at the sldebug prompt. For example, suppose you are at a breakpoint and you are logging time and output of your model as tout and yout. The following command creates a plot.

(sldebug ...) plot(tout, yout)

You cannot display the value of a workspace variable whose name is partially or entirely the same as that of a debugger command by entering it at the debugger command prompt. You can, however, use the eval command to work around this problem. For example, use eval('s') to determine the value of s rather than call the function step function.

Related Topics