Main Content

deleteOrphanLinks

Class: slreq.LinkSet
Namespace: slreq

Delete links with invalid source

Since R2024a

Description

example

count = deleteOrphanLinks(myLinkSet) deletes the links that have an invalid link source in the link set specified by myLinkSet and returns the number of deleted links.

Input Arguments

expand all

Link set, specified as an slreq.LinkSet object.

Output Arguments

expand all

Number of deleted links, returned as a double.

Examples

expand all

This example shows how to get and delete 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");

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

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

Delete the orphan links.

count = deleteOrphanLinks(myLinkSet)
count = 1

Confirm that there are no orphan links.

orphanLinks = getOrphanLinks(myLinkSet)
orphanLinks =

     []

Alternative Functionality

App

Use the Repair Invalid Links dialog box in the Requirements Editor to view the orphan links. For more information, see Resolve Links.

Version History

Introduced in R2024a