Main Content

deleteAttribute

Class: slreq.LinkSet
Namespace: slreq

Delete custom attribute from link set

Since R2020b

Syntax

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

Description

deleteAttribute(myLinkSet,name,'Force',true) deletes the custom attribute specified by name from the link set myLinkSet, even if the custom attribute is used by links in the link set.

deleteAttribute(myLinkSet,name,'Force',false) deletes the custom attribute specified by name from the link set myLinkSet only if the custom attribute is not used by links in the link set.

Input Arguments

expand all

Link set, specified as an slreq.LinkSet object.

Custom attribute name, specified as a character array.

Examples

expand all

This example shows how to delete a custom attribute.

Load the crs_req requirement files, which contain links for a cruise control system. Find a link set in the files.

slreq.load('crs_req');
ls = slreq.find('Type','LinkSet');

Delete the custom attribute named Target Speed Change from the link set. Because the Target Speed Change attribute is used by links, it can only be deleted by setting Force to true.Confirm that it was deleted successfully by accessing the CustomAttributeNames property for the link set.

deleteAttribute(ls,'Target Speed Change','Force',true)
ans = logical
   1

atrb1 = ls.CustomAttributeNames
atrb1 =

  0x0 empty cell array

Only Delete Custom Attribute if the Attribute is Unused

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

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

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

deleteAttribute(ls,'MyEditAttribute','Force',false)
ans = logical
   0

atrb3 = ls.CustomAttributeNames
atrb3 =

  0x0 empty cell array

Version History

Introduced in R2020b