| Simulink® | ![]() |
| On this page… |
|---|
Extent of Traceability in Embedded MATLAB™ Function Blocks Basic Workflow for Using Traceability Tutorial: Using Traceability in an Embedded MATLAB™ Function Block |
Like other Simulink® blocks, Embedded MATLAB™ Function blocks support bidirectional traceability, but extend navigation to lines of source code. That is, you can navigate between a line of generated code and its corresponding line of source code. In other Simulink blocks, you can navigate between a line of generated code and its corresponding object.
For information about how traceability works in Simulink blocks, see Tracing Generated Code Back to Your Simulink® Model in the Real-Time Workshop® User's Guide.
To enable traceability comments in your code, you must have a license for Real-Time Workshop® Embedded Coder™ software. These comments appear only in code that you generate for an embedded real-time (ert) based target.
Note Traceability is not supported for M-files that you call from an Embedded MATLAB Function block. |
The workflow for using traceability is described in Creating and Using a Code Generation Report in the Real-Time Workshop Embedded Coder User's Guide.
Here are the basic steps:
Open the Embedded MATLAB Function block in your Simulink model.
Define your system target file to be an embedded real-time (ert) target.
Enable traceability options.
Generate the source code and header files for your model.
Trace a line of code:
| To Trace: | Do This: |
|---|---|
| Line of source code to line of generated code | Right-click in a line in your source code and select Real-Time Workshop > Navigate to Code from the context menu |
| Line of generated code to line of source code | Click a hyperlink in the traceability comment in your generated code |
To learn how to complete each step in this workflow, see Tutorial: Using Traceability in an Embedded MATLAB™ Function Block
This example shows how to trace between source code and generated code in an Embedded MATLAB Function block in the eml_fire demo model. Follow these steps:
Type eml_fire at the MATLAB® prompt.
In the Simulink model window, double-click the flame block to open the Embedded MATLAB Editor.
In the Simulink model window, select Simulation > Configuration Parameters.
In the Real-Time Workshop pane, go to the Target selection section and enter ert.tlc for the system target file. Then click Apply.
In the Real-Time Workshop > Report pane, select the Create code generation report option.
This action automatically selects the Launch report automatically and Code-to-model options.
Select the Model-to-code option in the Navigation section. Then click Apply.
This action automatically selects all options in the Traceability Report Contents section.
Go to the Real-Time Workshop > Interface pane. In the Software environment section, select the continuous time option. Then click Apply.
In the Real-Time Workshop pane, click Build in the lower right corner.
This action generates source code and header files for the eml_fire model that contains the flame block. After the code generation process is complete, the code generation report appears automatically.

Click the eml_fire.c hyperlink in the report.
Scroll down through the code to see the traceability comments.

Click the <S2>:1:19 hyperlink in this traceability comment:
/* '<S2>:1:19' */Line 19 of the Embedded MATLAB function appears highlighted in the Embedded MATLAB Editor.

You can also trace a line in an Embedded MATLAB function to a line of generated code. For example, right-click in line 21 of your function and select Real-Time Workshop > Navigate to Code from the context menu.

The code location for line 21 appears highlighted in eml_fire.c.

![]() | Working with Frame-Based Signals | PrintFrame Editor | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |