Main Content

remove

Class: slreq.Requirement
Namespace: slreq

Remove requirement from requirement set

Description

count = remove(req) removes the requirement req and returns the number of requirements deleted. If req has child requirements, they are also deleted.

example

count = remove(parentReq,'PropertyName1',PropertyValue1,...,'PropertyNameN',PropertyValueN) removes child requirements of parentReq that match the properties specified by PropertyName and PropertyValue. The function returns the number of requirements deleted. The parent requirement is not removed.

Note

When you remove a requirement, the variable corresponding to the removed slreq.Requirement object remains in the workspace but is no longer a valid slreq.Requirement object.

Input Arguments

expand all

Requirement, specified as an slreq.Requirement object.

Parent requirement, specified as an slreq.Requirement object.

Requirement property name, specified as a character vector. See the valid property names in the Properties section of slreq.Requirement.

Example: 'Type', 'Id', 'Keywords'

Requirement property value, specified as a character vector, character array, datetime value, scalar, logical, or structure array. The value depends on the specified propertyName. See the valid property values in the Properties section of slreq.Requirement.

Example: 'Functional', '1.1.1', 'Design'

Output Arguments

expand all

Total number of requirements that were removed, returned as a double.

Examples

expand all

This example shows how to find and remove a single requirement.

Load a requirement set file. Find a requirement in the requirement set by using the ID number, then remove it.

rs = slreq.load('crs_req_func_spec.slreqx');
req = find(rs,'Type','Requirement','ID','#2');
count = remove(req)
count = 1

Cleanup

Clean up commands. Clear the open requirement sets without saving changes and close the open models without saving changes.

slreq.clear;
bdclose all;

This example shows how to remove a parent requirement and its children.

Load a requirement set and find a parent requirement by using the ID number. Confirm that it is a parent requirement by checking if it has children, then remove the requirement. When you remove a parent requirement, the children are also removed.

rs = slreq.load('crs_req_func_spec.slreqx');
parentReq1 = find(rs,'Type','Requirement','ID','#24');
childReqs1 = children(parentReq1)
childReqs1=1×12 Requirement array with properties:
    Type
    Id
    Summary
    Description
    Keywords
    Rationale
    CreatedOn
    CreatedBy
    ModifiedBy
    IndexEnabled
    IndexNumber
    SID
    FileRevision
    ModifiedOn
    Dirty
    Comments
    Index

count2 = remove(parentReq1)
count2 = 13

Cleanup

Clean up commands. Clear the open requirement sets without saving changes and close the open models without saving changes.

slreq.clear;
bdclose all;

This example shows how to remove child requirements that match a property type, and how to automate the process of removing all requirements with a matching property type.

Remove Child Requirements that Match Property Types

Load a requirement set file and find a parent requirement by using the ID number.

rs = slreq.load('crs_req_func_spec.slreqx');
parentReq = find(rs,'Type','Requirement','ID','#63');

Confirm that the requirement is a parent requirement by checking if it has children, and remove child requirements that match that revision number.

childReqs = children(parentReq)
childReqs=1×7 Requirement array with properties:
    Type
    Id
    Summary
    Description
    Keywords
    Rationale
    CreatedOn
    CreatedBy
    ModifiedBy
    IndexEnabled
    IndexNumber
    SID
    FileRevision
    ModifiedOn
    Dirty
    Comments
    Index

count1 = remove(parentReq,'FileRevision',54)
count1 = 4

Remove Multiple Requirements that Match Property Types

Create a requirements array by finding all requirements in the requirement set that were modified in revision 18.

reqs = find(rs,'Type','Requirement','FileRevision',18);

Initialize the count variable, then loop through the requirements array and delete all of the requirements. Increment the count variable each time a requirement is deleted, then display the total number of requirements deleted.

count2 = 0;
for i = 1:numel(reqs)
    count2 = count2 + remove(reqs(i));
end
count2
count2 = 4

Cleanup

Clean up commands. Clear the open requirement sets without saving changes and close the open models without saving changes.

slreq.clear;
bdclose all;

Version History

Introduced in R2018a