Main Content

rtwtrace

Trace a block to generated code in code generation report

Description

rtwtrace('blockpath') opens a code generation report that displays contents of the source code file and highlights the line of code corresponding to the specified block.

Before calling rtwtrace, make sure that:

  • You select an ERT-based model and enable model to code navigation.

    In the Configuration Parameters dialog box, select the Model-to-code parameter.

  • You generate code for the model by using the code generator.

  • Your build folder is under the current working folder. Otherwise, rtwtrace might produce an error.

example

rtwtrace('Simulink_identifier') opens a code generation report that displays contents of the source code file and highlights the line of code corresponding to the block identified by the Simulink® identifier (SID). SID is a unique designation for each block or element in the model.

rtwtrace('blockpath', 'hdl') opens a code generation report in HDL Coder™ that displays contents of the source code file and highlights the line of code corresponding to the specified block.

rtwtrace('blockpath', 'plc') opens a code generation report in Simulink PLC Coder™ that displays contents of the source code file and highlights the line of code corresponding to the specified block.

Examples

collapse all

Display the generated code for a block in the CustomCodeComments model in code generation report

Open the CustomCodeComments model.

openExample('CustomCodeComments')

Use the block path to trace to the block in the generated code.

rtwtrace('CustomCodeComments/Out1')

Input Arguments

collapse all

blockpath is a character vector enclosed in quotes specifying the full Simulink block path, for example, 'model_name/block_name'.

Example: 'CustomCodeComments/Out1'

Data Types: char

Simulink_identifier is a character vector enclosed in quotes specifying the Simulink identifier, for example, 'model_name:number'.

For more information, see Simulink.ID.getSID.

Example: 'CustomCodeComments:33'

Data Types: char

hdl is a character vector enclosed in quotes specifying that the code report is from HDL Coder.

Example: 'Out1'

Data Types: char

plc is a character vector enclosed in quotes specifying that the code report is from Simulink PLC Coder.

Example: 'Out1'

Data Types: char

Alternatives

To trace from a block in the model diagram, right-click a block and select C/C++ Code > Navigate to C/C++ Code.

Version History

Introduced in R2009b