Main Content

Simulink.dictionary.archdata.Constant

Store constant values in Architectural Data section of data dictionaries

Since R2023b

    Description

    Use a Simulink.dictionary.archdata.Constant object to represent a constant in the Architectural Data section of a data dictionary.

    Creation

    You can add a Simulink.dictionary.archdata.Constant object to a data dictionary in two ways.

    • Interactively create a Simulink.dictionary.archdata.Constant object by using the Architectural Data Editor.

    • Programmatically create a Simulink.dictionary.archdata.Constant object by using the addConstant function.

    archDataObj = Simulink.dictionary.archdata.create("dataDictionary.sldd");
    constant = addConstant(archDataObj,"myConst","Value",4)
    constant = 
    
      Constant with properties:
    
               Name: 'myConst'
              Value: 4
           DataType: 'double'
        Description: ''
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]
    

    Properties

    expand all

    Custom description of the constant, specified as a character vector.

    Example: 'Constant representing maximum RPM.'

    Data Types: char

    Name of the constant object, specified as a character vector or string scalar.

    Example: addConstant(archDataObj,"myConst")

    Data Types: char | string

    Simulink.dictionary.ArchitecturalData object that contains the constant.

    Example: Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Actual value of the constant, specified as any numeric value.

    Example: addConstant(archData,"myConst","Value",15)

    Example: addConstant(archData,"myConst","Value",-26)

    Example: addConstant(archData,"myConstant",Value=2)

    Object Functions

    moveToDictionaryMove architectural data of Simulink data dictionary to another data dictionary
    moveToDesignDataMove interfaces, data types, and constants in Architectural Data section of Simulink data dictionary to design data
    showView architectural data of Simulink data dictionary in Architectural Data Editor
    destroyDelete data element and remove from data interface

    Examples

    collapse all

    To add a constant to the data dictionary, use the addConstant function. For more examples of architectural data management workflows and related functions, see Store Data in Architectural Data Section Programmatically.

    Create or open a data dictionary. This example uses a previously created data dictionary myDictionary.sldd.

    dictName = "myDictionary.sldd";
    archData = Simulink.dictionary.archdata.open(dictName);
    

    Add a constant by using the addConstant function. Specify the name and value.

    myConst = addConstant(archData,"myConstant",Value=12)
    myConst = 
    
      Constant with properties:
    
               Name: 'myConstant'
              Value: 12
           DataType: 'double'
        Description: ''
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Version History

    Introduced in R2023b