Main Content

Simulink.dictionary.archdata.DataElement

Data element of data interface

Since R2023b

    Description

    A data element describes a part of a data interface, such as the structure of the transmitted data or other decomposition of the interface.

    Creation

    To create a Simulink.dictionary.archdata.DataElement object, add a data element to an existing Simulink.dictionary.archdata.DataInterface object using the addElement function.

    dataElementObj = addElement(dataInterfaceObj,"element")
    dataElementObj = 
    
      DataElement with properties:
    
               Name: 'element'
               Type: [1×1 Simulink.dictionary.archdata.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.dictionary.archdata.DataInterface]

    You can access an existing data element using the getElement function.

    Properties

    expand all

    Name of data element, specified as a character vector or string scalar.

    Example: "myElement"

    Data Types: char | string

    Type of the data element, specified as an object of one of the following types: Simulink.dictionary.archdata.AliasType, Simulink.dictionary.archdata.Datainterface, Simulink.dictionary.archdata.EnumType, Simulink.dictionary.archdata.NumericType, Simulink.dictionary.archdata.StructType, or Simulink.dictionary.archdata.ValueType.

    Description of the data element, specified as a character vector or string scalar.

    Example: "I am a data element."

    Data Types: char | string

    Dimensions of a data element, specified as a character vector representing a two element vector containing the dimensions of the element.

    Example: '[1 2]'

    Data Types: char

    Simulink.dictionary.archdata.DataInterface object that contains the data element.

    Object Functions

    destroyDelete data element and remove from data interface
    showView architectural data of Simulink data dictionary in Architectural Data Editor

    Examples

    collapse all

    This example shows how to add, get, and remove data elements from a data interface.

    Use the Simulink.dictionary.archdata.open function to open an existing data dictionary. This creates a Simulink.dictionary.ArchitecturalData object, archDataObj.

    archDataObj = Simulink.dictionary.archdata.open("myInterfaceDict.sldd")
    archDataObj = 
    
      ArchitecturalData with properties:
    
        DictionaryFileName: 'myInterfaceDict.sldd'
                Interfaces: [1×1 Simulink.dictionary.archdata.DataInterface]
                 DataTypes: [0×0 Simulink.dictionary.archdata.DataType]
                 Constants: [0×0 Simulink.dictionary.archdata.Constant]
    

    The data dictionary contains one data interface definition.

    interfaceObj = getInterface(archDataObj,"DataInterface")
    interfaceObj = 
    
      DataInterface with properties:
    
               Name: 'DataInterface'
        Description: ''
           Elements: [0×0 Simulink.dictionary.archdata.DataElement]
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Data interfaces are composed of data elements that describe parts of a data interface. This interface definitions contains two data elements.

    getElement(interfaceObj,"Element1")
    ans = 
    
      DataElement with properties:
    
               Name: 'Element1'
               Type: [1×1 Simulink.dictionary.archdata.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.dictionary.archdata.DataInterface]
    getElement(interfaceObj,"Element2")
    ans = 
    
      DataElement with properties:
    
               Name: 'Element2'
               Type: [1×1 Simulink.dictionary.archdata.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.dictionary.archdata.DataInterface]

    Use the addElement function to add a new data element to the data interface.

    dataElem1 = addElement(interfaceObj,"element3")
    dataElem1 = 
    
      DataElement with properties:
    
               Name: 'element3'
               Type: [1×1 Simulink.dictionary.archdata.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.dictionary.archdata.DataInterface]

    You can get an existing data element using the getElement function.

    dataElem3 = getElement(interfaceObj,"element3")
    dataElem3 = 
    
      DataElement with properties:
    
               Name: 'element3'
               Type: [1×1 Simulink.dictionary.archdata.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.dictionary.archdata.DataInterface]

    Remove a data element from an interface using the removeElement function.

    removeElement(interfaceObj,"element3")

    Version History

    Introduced in R2023b