Main Content

add

Class: slreq.Requirement
Namespace: slreq

Add child requirement

Syntax

reqChild = add(req)
reqChild = add(req,PropertyName,PropertyValue,...,PropertyNameN,PropertyValueN)

Description

reqChild = add(req) adds a child requirement to the requirement req and returns a handle to the child requirement.

reqChild = add(req,PropertyName,PropertyValue,...,PropertyNameN,PropertyValueN) adds a child requirement with the properties and property values specified by PropertyName and PropertyValue.

Input Arguments

expand all

Requirement, specified as an slreq.Requirement object.

Requirement property name, specified as a string scalar or a character vector.

You can only enter an slreq.Requirement property where the SetAccess attribute is public.

Example: "Summary"

Requirement property value, specified as an string scalar or a character vector.

Output Arguments

expand all

New child requirement, returned as an slreq.Requirement object.

Examples

expand all

This example shows how to add a child requirement under a requirement.

Load the requirement set myReqSet, which does not contain any requirements.

rs = slreq.load("myReqSet");

Use the add method to add a top-level requirement to the requirement set.

req = add(rs);

Use the add method to add a child requirement under the requirement.

newReq = add(req)
newReq = 
  Requirement with properties:

            Type: 'Functional'
              Id: '#3'
         Summary: ''
     Description: ''
        Keywords: {}
       Rationale: ''
       CreatedOn: 12-Feb-2024 23:41:09
       CreatedBy: 'batserve'
      ModifiedBy: 'batserve'
    IndexEnabled: 1
     IndexNumber: []
             SID: 3
    FileRevision: 1
      ModifiedOn: 12-Feb-2024 23:41:09
           Dirty: 1
        Comments: [0x0 struct]
           Index: '1.1'

Get the value of the Index property for the new requirement.

idx = newReq.Index
idx = 
'1.1'

The value indicates that the new requirement is a child requirement of the original requirement.

Cleanup

Discard the requirement set without saving.

discard(rs);

Tips

  • To add a top-level requirement to a requirement set, use the add method of slreq.ReqSet. To add a referenced requirement as a child of another referenced requirement, use the add method of slreq.Reference. To add a justification as a child of another justification, use the add method of slreq.Justification.

Version History

Introduced in R2018a