Main Content

addConstant

Add constant to Architectural Data section of Simulink data dictionary

Since R2023b

    Description

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

    example

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

    example

    Examples

    collapse all

    To add a Simulink.dictionary.archdata.Constant object 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.

    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 Simulink.dictionary.archdata.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