Main Content

move

Class: slreq.Requirement
Namespace: slreq

Move requirement in hierarchy

Since R2020b

Syntax

tf = move(req1,location,req2)

Description

tf = move(req1,location,req2) moves requirement req1 under, before, or after requirement req2 depending on the location specified by location. The function returns 1 if the move is executed without error.

Input Arguments

expand all

Requirement to move, specified as an slreq.Requirement object.

Requirement move location, specified as 'under', 'before', or 'after'.

Requirement, specified as an slreq.Requirement object.

Output Arguments

expand all

Paste success status, returned as a 1 or 0 of data type logical.

Examples

expand all

This example shows how to move a requirement under, before, or after another requirement.

Load the crs_req_func_spec requirement file, which describes a cruise control system, and assign it to a variable. Find two requirements by index. The first requirement will be moved in relation to the second requirement.

rs = slreq.load('crs_req_func_spec');
req1 = find(rs,'Type','Requirement','Index','1');
req2 = find(rs,'Type','Requirement','Index','2');

Move Under a Requirement

Move the first requirement, req1, under the second requirement, req2. The first requirement becomes the last child requirement of requirement req2, and req2 moves up one in the hierarchy, which you can verify by checking the index of req1 and req2. The old indices of req1 and req2 were 1 and 2, respectively.

tf = move(req1,'under',req2);
req1.Index
ans = 
'1.3'
req2.Index
ans = 
'1'

Move Before a Requirement

Move the first requirement, req1, before the second requirement, req2. Confirm that the requirement was moved correctly by checking the indices of req1 and req2. The indices of req1 and req2 are now the same as they were originally: 1 and 2, respectively.

tf = move(req1,'before',req2);
req1.Index
ans = 
'1'
req2.Index
ans = 
'2'

Move After a Requirement

Move the first requirement,req1, after the second requirement, req2. When you move requirement req1 down in the hierarchy, requirement req2 also moves up, which you can verify by checking the indices of req1 and req2.

tf = move(req1,'after',req2);
req1.Index
ans = 
'2'
req2.Index
ans = 
'1'

Version History

Introduced in R2020b