Load and Resolve Links
When you open or load an artifact that has incoming or outgoing links, Requirements Toolbox™ loads the link sets that contain those links. If the link sets have registered requirement sets, the software also loads those requirement sets. Loading registered requirement sets can further load links if the requirement set has incoming or outgoing links to additional artifacts.
When you load links, the software may identify unresolved links where the source or destination item are not available. You can resolve links by loading the artifact that contains the unloaded item or by repairing the link manually.
Load Artifacts and Associated Link Sets
When you load artifacts such as requirement sets, Simulink® models, or MATLAB® code that have incoming or outgoing links, Requirements Toolbox loads the link sets that contain those links.
For example:
Open the
ShortestPathproject. At the MATLAB command line, enter this command:openExample("slrequirements/ShortestPathExample")Open the
shortest_path_func_reqsrequirement set. At the MATLAB command line, enter:Theslreq.open("shortest_path_func_reqs");shortest_path_func_reqsrequirement set has outgoing links to MATLAB code ranges inshortest_path.mandgraph_unit_tests.m.View the loaded link sets. In the Requirements Editor, click Show Links. The software loaded the link sets associated with
shortest_path.mandgraph_unit_tests.m.
Load Registered Requirement Sets
When you create a link to a requirement, the requirement set that contains the
requirement becomes registered to the link set. You can view the registered requirement
sets for a link set by using the getRegisteredReqSets method.
When you load a link set that has registered requirements, Requirements Toolbox also loads those requirement sets. If those requirement sets have links to additional artifacts, the software also loads the link sets that contain those links.
For example:
Clear the loaded requirement sets and link sets by entering this command at the MATLAB command line:
slreq.clear
Open the
ShortestPathproject by entering this command at the MATLAB command line:openExample("slrequirements/ShortestPathExample")Open the
graph_unit_tests.mMATLAB code file. At the MATLAB command line, enter:Theedit graph_unit_tests.mgraph_unit_tests.mfile has outgoing links to requirements.View the loaded link sets. Open the Requirements Editor.
In the Requirements Editor, click Show Links. The software loadedslreq.editor
graph_unit_tests.slmx, which is the link set that contains the outgoing links fromgraph_unit_tests.m.
The
graph_unit_tests.mfile has outgoing links to theshortest_path_tests_reqsandshortest_path_func_reqsrequirement sets, so they are registered to thegraph_unit_testslink set.View the loaded requirement sets. In the Requirements Editor, click Show Requirements. Because the
shortest_path_tests_reqsandshortest_path_func_reqsrequirement sets are registered to thegraph_unit_testslink set, they software also loaded them.
The
shortest_path_func_reqsrequirement set also has incoming links fromshortest_path.mstored inshortest_path.slmx.View the loaded link sets again. In the Requirements Editor, click Show Links. Because the software loaded the
shortest_path_func_reqsrequirement set, it also loaded the link set that contains its incoming links,shortest_path.slmx.
Unregister Requirement Sets
To unregister a requirement set from a link set, use the updateRegisteredReqSets method. You can only unregister a requirement
set from a link set if the requirement set does not have incoming links stored in
the link set.
Resolve Links
An unresolved link has a source item or destination item that is not available. Items can be unavailable because:
The artifact that contains the source or destination item is not loaded.
For example, loading a requirement set that has incoming links from a Simulink model also loads the link set that belongs to the model. However, if you do not load the Simulink model, the links are unresolved.
The artifact is loaded, but the specified ID does not exist.
For example, if you delete a linked requirement, the link becomes unresolved because the stored ID no longer corresponds to a valid item.
Links that are unresolved because the specified ID does not exist are called invalid links. Links that have invalid sources are called orphan links and links that have invalid destinations are called broken links.
To see the unresolved links, in the Requirements Editor, click
Show Links. Unresolved links have the unresolved link icon
.
To resolve a link with an unloaded source or destination item, load the artifact that
contains the item. Load the artifact by selecting the link in the Requirements
Editor and, in the right pane, under Properties, click
the source or destination item that has a warning icon
.
To resolve invalid links:
In the Requirements Editor, select Show Links. Select a link set or a link and, in the Links section, select Resolve link issues > Repair invalid links. The Repair Invalid Links dialog box opens.

In the Repair Invalid Links dialog:
Update the source or destination ID by manually specifying the ID in the Update to field.
Update the source or destination to the currently selected item in the source or destination artifact by clicking Use current.
Update the source or destination artifact by clicking Browse and selecting an artifact.
Delete the link by clicking Delete link.
If there are links in the link set that have the same missing source or destination, you can apply the same fix to those links by selecting the check box at the bottom of the dialog box.
If you opened the Repair Invalid links dialog for a link set, you can repair or delete additional links in the link set by using the < and > buttons to navigate the links.
Close the dialog by clicking OK.
Save the link set. In the Requirements Editor, select the link set and, in the File section, click Save.
You can also repair orphan links in the current file in the MATLAB Editor by using the Requirements Traceability panel. Repair the link by double-clicking one of the orphan items in red text and using the Repair Invalid Links dialog box. For more information, see Identify and Repair Orphan Links.

Resolve Links Programmatically
To resolve or delete invalid links in a link set:
Get a handle to the link set by using the
slreq.findfunction.Get the broken links by using the
getBrokenLinksmethod. Get the orphan links by using thegetOrphanLinksmethod.Repair the links by using the
setSourceandsetDestinationmethods.Alternatively, delete the links. Delete the orphan links by using the
deleteOrphanLinksmethod. Delete the broken links by using theremovemethod.Save the link set by using the
savemethod.
Alternatively, to resolve or delete individual invalid links:
Get a handle to the link by using the
slreq.findfunction or thefindmethod.Tip
You can find links by destination attributes by using the
slreq.findfunction or thefindmethod. For more information, see Find Links by Destination Attributes.Repair the link by using the
setSourceorsetDestinationmethod or delete the link by using theremovemethod.Get a handle to the link set by using the
linkSetmethod.Save the link set by using the
savemethod.
To fix broken links that point to a requirement set that you renamed,
use the updateDocUri method.
Unload Link Information
To unload link sets from memory, close both the source and destination artifacts that contain the linked items. If you close only the source artifact or only the destination artifact, the links remain loaded.
Alternatively, you can unload link sets by using the slreq.clear function to clear the loaded requirement sets and link sets
and close the Requirements Editor and Traceability Matrix windows.
See Also
Requirements
Editor | getRegisteredReqSets | updateRegisteredReqSets