Main Content


Class: slreq.Link
Namespace: slreq

Set requirement link source

Since R2019b



setSource(myLink,src) sets the link source to the item specified by src for the link myLink. You can set a link source only to a linkable item that belongs to the current source artifact for myLink.

Input Arguments

expand all

Link, specified as an slreq.Link object.

Link source item, specified as a:


expand all

This example shows how to find and repair orphan links.

Load the myAddRequirements requirement set, which contains requirements for a MATLAB® function that adds two inputs and outputs the result.

rs = slreq.load("myAddRequirements");

The myAddRequirements requirement set has incoming links from lines of code in the myAddOrphan MATLAB code file. Get a handle to the link set.

myLinkSet = slreq.find(Type="LinkSet");

Find the orphan links in the link set. Display the number of orphan links.

orphanLinks = getOrphanLinks(myLinkSet);
numOrphanLinks = numel(orphanLinks)
numOrphanLinks = 1

The source of the orphan link is line 2 in the myAddOrphan MATLAB code file. Get the line range object associated with that line of code.

lineRange = slreq.getTextRange("myAddOrphan.m",2);

Repair the orphan link by using the setSource method.


Confirm that there are no orphan links.

orphanLinks = getOrphanLinks(myLinkSet)
orphanLinks =


Version History

Introduced in R2019b