Main Content

setAttribute

Class: slreq.Link
Package: slreq

Set link custom attributes

Syntax

setAttribute(myLink,name,value)

Description

setAttribute(myLink,name,value) sets the value specified by value of the custom attribute specified by name for the link myLink.

Input Arguments

expand all

Link, specified as an slreq.Link object.

Custom attribute name, specified as a character array.

Custom attribute value, specified as a character array, double, logical or datetime. The data type depends on the custom attribute type.

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 object
  1x12 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'

Cleanup

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

slreq.clear;
bdclose all;
Introduced in R2020b