Main Content

setAttribute

Class: slreq.Link
Namespace: slreq

Set link property values

Since R2020b

Syntax

setAttribute(myLink,propertyName,propertyValue)

Description

setAttribute(myLink,propertyName,propertyValue) sets a link property, propertyName, to the value specified by propertyValuefor the link myLink. The property can be a built-in property, a custom attribute, or a stereotype property.

Note

To set the value of a stereotype property, you must pass the fully qualified name of the property. For example, the fully qualified name for a property called Status in a stereotype called myStereotype in a profile called myProfile is myProfile.myStereotype.Status.

Input Arguments

expand all

Link, specified as an slreq.Link object.

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

Example: "Description"

Link property value, specified as a:

  • String scalar

  • Character array

  • boolean

  • datetime

  • single

  • double

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • enumeration

The data type depends on the type of the built-in property, custom attribute, or stereotype property.

Examples

expand all

This example shows how to set the attribute value of a specified custom attribute for a link.

Load the crs_req requirement files, which contain links for a cruise control system.

slreq.load('crs_req');
slreq.load('crs_req_func_spec');

Create a links array containing all links. Get one link from the array.

linksArray = slreq.find('Type','Link')
linksArray=1×12 Link array with properties:
    Type
    Description
    Keywords
    Rationale
    CreatedOn
    CreatedBy
    ModifiedOn
    ModifiedBy
    Revision
    SID
    Comments

lk = linksArray(1);

Custom attribute Target Speed Change, tracks whether the linked requirements are related to incrementing or decrementing the speed, or not related at all. Set the value of Target Speed Change to Unset for your link. Then use getAttribute to confirm that the value was set correctly.

setAttribute(lk,'Target Speed Change','Unset');
value = getAttribute(lk,'Target Speed Change')
value = 
'Unset'

Tips

  • To set property values for requirements, use the setAttribute method.

Version History

Introduced in R2020b