Main Content

addConstant

Add constant to the Architectural Data section of Simulink data dictionary

Since R2023b

    Description

    example

    constObj = addConstant(archDataObj,constName) adds a constant with the specified name constName to the archDataObj, the Architectural Data section of a data dictionary and returns the constant object that represents the constant.

    example

    constObj = addConstant(archDataObj,constName,value) adds a constant with the specified value to the data dictionary and returns a constant object that represents the constant.

    Examples

    collapse all

    To add a constant to the data dictionary, use the addConstant function. For an example that shows more of the workflow for related functions, see Create Architectural Data Object and Use It to Configure Architectural Data.

    archDataObj = Simulink.dictionary.archdata.open("MyInterfaces.sldd");
    myConst = addConstant(archDataObj,"myConstant")
    myConst = 
    
      Constant with properties:
    
               Name: 'myConstant'
              Value: 0
           DataType: 'double'
        Description: ''
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Add a constant with a specified value.

    myCylinders = addConstant(archDataObj,"numOfCylinders",Value=4)
    myCylinders = 
    
      Constant with properties:
    
               Name: 'numOfCylinders'
              Value: 4
           DataType: 'double'
        Description: ''
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Input Arguments

    collapse all

    Architectural Data object, specified as a Simulink.dictionary.ArchitecturalData object.

    Constant definition name in Constants property array of archDataObj, specified as a character vector or string scalar.

    Example: "numOfCylinders"

    Value assigned to the constant object constObj.

    Output Arguments

    collapse all

    Object representing a constant in the Constants property array of archDataObj, returned as a Simulink.dictionary.archdata.Constant object.

    Version History

    Introduced in R2023b