Main Content

deleteAttribute

Class: slreq.ReqSet
Namespace: slreq

Delete custom attribute from requirement set

Since R2020b

Syntax

deleteAttribute(rs,name,'Force',true)
deleteAttribute(rs,name,'Force',false)

Description

deleteAttribute(rs,name,'Force',true) deletes the custom attribute specified by name from the requirement set rs, even if the custom attribute is used by requirements in the requirement set.

deleteAttribute(rs,name,'Force',false) deletes the custom attribute specified by name from the requirement set rs only if the custom attribute is not used by requirements in the requirement set.

Input Arguments

expand all

Requirement set, specified as an slreq.ReqSet object.

Custom attribute name, specified as a character array.

Examples

expand all

This example shows how to delete a custom attribute.

Load crs_req_func_spec, which is the requirement file for a cruise control system. Find a requirement set in the files.

slreq.load('crs_req_func_spec');
rs = slreq.find('Type','ReqSet');

Add an Edit custom attribute to the requirement set. Confirm that it was successfully added by accessing the CustomAttributeNames property for the requirement set.

addAttribute(rs,'MyCheckbox','Checkbox')
atrb1 = rs.CustomAttributeNames
atrb1 = 1x1 cell array
    {'MyCheckbox'}

Find a requirement in the requirement set. Set the custom attribute value for the requirement using setAttribute.

req = find(rs,'ID','#1');
setAttribute(req,'MyCheckbox',true)

The custom attribute MyCheckbox is now used by a requirement. Delete the requirement by using deleteAttribute with 'Force' set to true. Confirm the deletion by accessing the CustomAttributeNames property for the requirement set.

deleteAttribute(rs,'MyCheckbox','Force',true)
atrb2 = rs.CustomAttributeNames
atrb2 =

  0x0 empty cell array

Only Delete Custom Attribute if the Attribute is Unused

Add an Edit custom attribute to the requirement set. The attribute is unused because the value is not set for any links. Confirm that it added by accessing the CustomAttributeNames property for the requirement set.

addAttribute(rs,'MyEditAttribute','Edit')
atrb3 = rs.CustomAttributeNames
atrb3 = 1x1 cell array
    {'MyEditAttribute'}

You can delete the attribute only if the attribute is unused by setting Force to false. If the attribute is used by links, then an error will occur. Confirm the deletion by accessing the CustomAttributeNames property for the requirement set.

deleteAttribute(rs,'MyEditAttribute','Force',false)
atrb4 = rs.CustomAttributeNames
atrb4 =

  0x0 empty cell array

Version History

Introduced in R2020b