Main Content


Class: slreq.Link
Package: slreq

Set requirement link source

Since R2019b




setSource(myLink,src) sets the link source item src for the slreq.Link object myLink. You can set a link source only to a linkable item that belongs to the original link source artifact.

Input Arguments

expand all

Handle to a link, specified as an slreq.Link object.

Item to serve as the link source, specified as a Requirements Toolbox linkable item. See Linkable Items.


Set Simulink Blocks as Link Sources

% Set the Gain block in model myModel as the source for link myLink
setSource(myLink, 'myModel/Gain');

Set Simulink Test Objects as Link Source

% Create a test file, test suite, and a test case
myTestfile = sltest.testmanager.TestFile('my_test_file.mldatx');
myTestsuite = sltest.testmanager.TestSuite(myTestfile,'My Test Suite');
myTestcase = sltest.testmanager.TestCase(myTestsuite,'equivalence','Equivalence Test Case');

% Create a link from the test case to requirement myReq
myLink = slreq.createLink(myTestcase, req);

% Set the link source to the test suite
setSource(myLink, myTestsuite);

Set Stateflow Objects as Link Sources

% Get Stateflow Root Handle
rt = sfroot;

% Find the state with the name 'Intermediate'
myState = rt.find('-isa', 'Stateflow.State', 'Name', 'Intermediate');

% Set the source for link myLink to myState
setSource(myLink, myState);

Set Simulink Data Dictionary Entries as Link Sources

% Get handle to Simulink data dictionary entry
myDict ='myDictionary.sldd');
dataSectObj = getSection(myDict,'Design Data');
myDictEntry = getEntry(dataSectObj,'myEntry');

% Set the source for link myLink to myDictEntry
setSource(myLink, myDictEntry);

Change a Link Source to a Different Source Item

% Get destination of link link_1
dest = destination(link_1);

% Create a new link, link_2, with source newSrc and destination dest
link_2 = slreq.createLink(newSrc, dest);

% Copy link properties
link_2.Description = link_1.Description;
link_2.Rationale = link_1.Rationale;
link_2.Keywords = link_1.Keywords;
comments = link_1.Comments;
for i = 1:length(comments)

% Delete link_1

Version History

Introduced in R2019b