To create requirements traceability links from MATLAB® code lines to requirements in the Requirements Editor, use the Requirements context menu in the MATLAB Editor.
Load the requirement set that contains the requirement that you want to link to.
Navigate to the Requirements Editor and select the requirement.
In the MATLAB Editor, select the line or lines of code that you want to link.
Right-click your selection.
From the context menu, select Requirements > Link to Selection in Requirements Browser.
Simulink® Requirements™ creates a traceability link from the MATLAB code lines to the selected requirement in the Requirements Editor. Navigate from your requirements to the MATLAB code lines by using the navigation links available from the Links pane in the Requirements View of the Requirements Editor.
Create requirements traceability links between MATLAB code lines and requirements in requirement sets by using the Outgoing Links dialog box.
Load the requirement set that contains the requirement that you want to link to.
Navigate to the Requirements Editor and select the requirement.
In the MATLAB Editor, select the line or lines of code that you want to link to the requirement.
Right-click your selection.
From the context menu, select Requirements > Open Outgoing Links dialog.
In the Outgoing Links dialog box, click New.
From the Document type drop-down list, select
Requirement Set
.
Populate the Document field and the requirement Description by clicking Use current.
Click OK.
Navigate from your requirements to MATLAB code lines by using the navigation links available from the Links pane in the Requirements View of the Requirements Editor.
Note
When you link code lines from a MATLAB-based Simulink test to a requirement, the code lines that you select determine the type of link and the test to which it is added. SeeTest Models Using MATLAB-Based Simulink Tests (Simulink Test) .
To create requirements traceability links from MATLAB code lines to selections in Microsoft® Word, Microsoft Excel®, or IBM® Rational® DOORS® documents, use shortcuts in the Requirements Traceability context menu.
In your requirements document, select the target requirement for the traceability link that you want to create.
In the MATLAB Editor, select the line or lines of code that you want to link to the requirement.
In the MATLAB Editor, right-click your selection.
From the context menu, select Requirements. Depending on the type of your requirements document, select one of these options:
Link to Selection in Word
Link to Selection in Excel
Link to Selection in DOORS
The software creates a traceability link from the selected MATLAB code range to the selection in the requirements document. If you have bidirectional linking enabled, the software also inserts a navigation object for the selection in the requirements document. The navigation object links to the selected MATLAB code range.
You can create, edit, and delete traceability links through the Outgoing Links dialog box. To open the Outgoing Links dialog box:
In the MATLAB Editor, select the line or lines of code that you want to link to requirements.
Right-click your selection.
From the context menu, select Requirements > Open Outgoing Links dialog.
Review traceability in your MATLAB code by highlighting code lines that have requirements links.
To highlight traceability links in your MATLAB code, do one of the following:
In the View tab, in the Display section, select Highlight Traceability.
In the MATLAB Editor, right-click in a line of code with a traceability link. From the context menu, select Requirements > Enable Traceability Highlighting.
To turn off highlighting of traceability links in your MATLAB code, do one of the following:
In the View tab, in the Display section, clear Highlight Traceability.
In the MATLAB Editor, right-click in a line of code with a traceability link. From the context menu, select Requirements > Disable Traceability Highlighting.
To remove requirements traceability links from a line or lines of MATLAB code:
In the MATLAB Editor, right-click within a range of code that has requirements traceability links.
From the context menu, select Requirements > Delete All Links.
All links to requirements from this MATLAB code range are deleted. Links to this MATLAB code range from external requirements documents are not deleted.
If you have links to MATLAB code ranges from external requirements documents, you can delete the targets for these links from your MATLAB code.
To remove requirements traceability targets from a line or lines of MATLAB code:
Delete outgoing links as described in Delete Links to Requirements from MATLAB Code Lines.
In the MATLAB Editor, right-click within a previously linked range of code.
From the context menu, select Requirements > Discard Named Range.
When you discard a named range, links to that MATLAB code range from external documents no longer work. Discarding named ranges does not delete navigation objects in external requirements documents.
You can create MATLAB code traceability links for:
Lines of MATLAB code in a standalone file.
Lines of MATLAB code inside a MATLAB Function block.
You can create links from a line or lines of MATLAB code to:
Selections in Simulink Requirements.
Objects in Simulink models.
Targets in Microsoft Word or Microsoft Excel documents.
Targets in IBM Rational DOORS databases.
Targets in text, HTML, or PDF documents.
HTTP URLs.
Bidirectional linking is supported for targets in MATLAB, Simulink, Microsoft Word, Microsoft Excel, and IBM Rational DOORS. Bidirectional linking creates links to and from the selected link destination. To enable bidirectional linking, in the Requirements Settings dialog box, under the Selection Linking tab, select Modify destination for bidirectional linking. For more information, see Selection Linking Tab.
You can also create links to MATLAB code lines from any external application that supports HTTP navigation.
Embedded Coder® embeds requirements traceability links for MATLAB files that are saved externally from the Simulink model and referenced from MATLAB Function blocks in Simulink. In the code generation report, click the hyperlink to navigate to the corresponding requirement in the Requirements Editor. See Generate Code for Models with Requirements Links.
In a standalone MATLAB file, you can create, navigate, and delete traceability links for
lines of code without changing the MATLAB file. The Requirements Management Interface (RMI) stores
requirements traceability data for a MATLAB file in a .req
file with the same name and
location as the MATLAB file.
If you want to create traceability links for lines of code in a MATLAB
Function block, set the parent model to store requirements data
externally. For a new model, see Requirements Link Storage.
For an existing model, see Move Internally Stored Requirements Links to External Storage.
When you create traceability links for code inside a MATLAB
Function block, the RMI stores them in a .req
file for the parent model. The .req
file for the model
contains requirements traceability data for linked model objects and for linked
code in MATLAB Function blocks in the model.
The software does not support traceability links for overlapping regions of MATLAB code. If one linked range of code completely overlaps another smaller region of code, the link for the larger range takes precedence over the link for the smaller range. To avoid complications from overlapping linked ranges, when you create traceability links for MATLAB code lines, choose ranges of code that do not overlap.
You can cut or copy a selection of code that has traceability links. When you paste that selection, the software attempts to recreate the corresponding traceability links. Depending on location and code formatting, you might need to recreate the traceability links manually.
If you select code that has traceability links and drag that code to a new location, you might need to recreate traceability links for the code in the new location.
Requirements linked to individual MATLAB code lines inside a MATLAB Function block appear in HTML requirements traceability reports but do not appear the Simulink Report Generator™ Web View. See Create and Use a Web View (Simulink Report Generator).
Requirements traceability is not supported for MATLAB Live Editor.