Main Content

Make Requirements Fully Traceable with a Traceability Matrix

This example shows how to find requirements that are not traceable to Model-Based Design items, and how to trace those requirements by creating links with a traceability matrix.

A traceability matrix displays links between items in Model-Based Design artifacts such as Requirements Toolbox™ objects, Simulink® model elements, Simulink Test™ objects, and MATLAB® code lines. You can apply filters and focus only on the items that you want to see. You can use the matrix to identify unlinked items and implement them in your design.

To read more about how to use the traceability matrix, see Track Requirement Links with a Traceability Matrix.

Open the Requirements Definition for a Cruise Control Model project. Load the crs_req_func_spec requirement set.


Generate a Traceability Matrix

Open the Traceability Matrix window.


In the Traceability Matrix window, click Add. In the Select Artifacts dialog, set Left to crs_req_func_spec.slreqx and set Top to crs_controller.slx. Then click Generate Matrix. A traceability matrix is generated with the specified requirement set on the left and the Simulink model on the top.

Identify Unlinked Requirements

To identify unlinked items, click Highlight Missing Links. Unlinked requirements are highlighted in yellow in the left column and unlinked model elements are highlighted in the top row.

Scroll to the System Interface > Inputs parent requirement. Click Scope to focus the matrix view on that hierarchy. The child requirements under Inputs do not have links to the blocks in the Simulink model. However, the traceability matrix that you created only shows links between the crs_req_func_spec requirement set and the crs_controller model. The crs_req_func_spec requirement set may have more links to other artifacts within your project.

Generate a Traceability Matrix with Multiple Artifacts

To view links between multiple artifacts at the same time, you can create a multi-artifact matrix. Click Configure Matrix to add more artifacts to your matrix. In the Configure Matrix dialog box, in the Available Artifacts pane, select crs_req_func_spec.slreqx. The artifacts that have links between the selected artifact are highlighted in the Available Artifacts pane. In this case, each artifact contains links between the crs_req_func_spec requirement set, except for crs_req_func_spec.slreqx itself. Drag all of the highlighted artifacts to the top artifact list. The expand icon () in the matrix preview indicates that there are links between items in these artifacts.

Click Update Matrix to add the artifacts to your traceability matrix. Starting from the far-left column in the top row, select each artifact and click Collapse All. The blue lines in the matrix indicate where one artifact ends and another begins.

Select the Inputs parent requirement and click Scope to focus on the Inputs child requirements. Click Highlight Missing Links. Now you can see that some of the child requirements under Inputs link to items in the crs_plant model.

Link Unlinked Inputs to Model Elements

The crs_controller and crs_plant models contain model elements that are related to the Inputs child requirements, however not all of the Inputs child requirements are linked. Link all of the Inputs child requirements to the model elements for full traceability. First, click Configure Matrix and remove all of the artifacts from the Traceability Matrix except for crs_req_func_spec on the left, and crs_controller and crs_plant on the top by right-clicking the artifacts and selecting Remove Artifacts. Click Update Matrix. In the updated matrix, select the Inputs parent requirement and click Scope to focus on the Inputs child requirements.

Some of the child requirements link to items in crs_plant. Link the remaining unlinked Inputs child requirements to model elements in crs_controller. Select the cell corresponding to crs_controller and click Scope.

To focus on the unlinked requirements, apply the Missing Links filter. In the Filter Panel, under Left, under Link, click Missing Links. The filter omits rows with linked items. You can verify this by clicking Highlight Missing Links.

Collapse the CruiseControlMode, DriverSwRequest and TargetSpeedThrottle subsystems by select each subsystem and clicking Collapse All. Create a link between the Enable Switch requirement and the enbl block by selecting the cell corresponding to those two items and clicking Create. In the Create Links dialog box, set Type to Implements, then click Create to create a link between the two items.

You can create multiple links at a time when you hold Ctrl, select the cells where you want to create links, and click Create Links. Create links between the remaining requirements and the corresponding model element:

  • The Cancel Switch requirement and the cncl block

  • The Set Switch requirement and the set block

  • The Resume Switch requirement and the resume block

  • The Increment Switch requirement and the inc block

  • The Decrement Switch requirement and the dec block

  • The Key Position requirement and the key block

In the Create Links dialog, set Type to Implements for all of the links.

Clear the Missing Links filter by clicking Clear Filter in the top artifact list. Click Show All to show all of the artifacts. All of the Inputs child requirements link to design items, so they are no longer highlighted. Collapse the hierarchies under crs_controller and crs_plant. The expand icon () indicates that all of the Inputs child requirements are linked.

Open Items in Artifact Context

You can open items in rows and columns in their artifact context by double-clicking the cell corresponding to an item. For example, double-clicking a cell corresponding to a Simulink block opens the Simulink model and subsystem that the block is in.

Open the Enable Switch requirement in the Requirements Editor by double-clicking it. Add additional text to the requirement Description: "The Cruise button enables the cruise control as long as all other conditions are met." Then click Save.

In the Requirements Editor, the requirement summary and the associated link (listed in the Details pane, under Links) are highlighted in red because the link associated with this requirement has a change issue.

View and Clear Change Issues

When you change a requirement that is linked to another item, the requirement is highlighted in red to indicate that there is a change issue associated with the link. The link has a change issue because you changed the description for the Enable Switch requirement.

Return to the Traceability Matrix. Click Update to refresh the matrix. Select the Inputs parent requirement and click Scope to focus on the Inputs child requirements. Click Highlight Missing Links > Highlight Changed Links, then click Highlight Missing Links > Show Changed Links Only. The links that have associated change issues are shown, and the requirement, linked item, and link are highlighted in red.

Because you changed only the description, the change did not affect the requirement implementation or verification. Clear the change issue by selecting the cell containing the link, then click Clear Change Issue. Under Comment, enter "Added additional information to the requirement description." Then click Clear All.

You can view the comment when you select the link in the Requirements Editor, in the Details pane, under Comments.

Generate a Report from the Traceability Matrix

Update the matrix to reflect the cleared change issues by clicking Update. Select Inputs parent requirement and click Scope. Expand all links by selecting the cell containing the expand icon () and clicking Expand All. Collapse any hierarchies that don't contain links by clicking Collapse All. This view shows the links to the Inputs child requirements. Generate an HTML report that contains a static snapshot of the current view of the traceability matrix by clicking Export > Generate HTML Report. Select a location to save the file and click Save.

See Also


Related Topics