Main Content

rtwtrace

Trace a block to generated code in code generation report

Description

example

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.

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. For more information, see Simulink Identifiers.

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

Display Generated Code for a Block

Display the generated code for block Out1 in the model rtwdemo_comments in code generation report:

% Using block path
rtwtrace('rtwdemo_comments/Out1')

% Using Simulink identifier
rtwtrace('rtwdemo_comments:33')

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: 'rtwdemo_comments/Out1'

Data Types: char

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

Example: 'rtwdemo_comments: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.

Introduced in R2009b