Main Content

Simulink.dictionary.archdata.StructType

Structure data type

Since R2023b

    Description

    A StructType object represents a structure data type containing elements represented by Simulink.dictionary.archdata.StructElement objects.

    Creation

    Create a StructType object using the addStructType function.

    structTypeObj = addStructType(archDataObj,"structType1")

    Properties

    expand all

    Struct type name, specified as a character vector or string scalar.

    Data Types: char | string

    Description of the struct type, specified as a character vector or a string scalar.

    Data Types: char | string

    Struct elements contained in the struct type object, specified as an array of Simulink.dictionary.archdata.StructElement objects.

    Architectural Data object containing the struct type, specified as a Simulink.dictionary.ArchitecturalData object.

    Object Functions

    addElementAdd struct element to struct type
    getElementGet struct element from struct type
    removeElementRemove element from struct type
    convertToDataInterfaceConvert struct type to data interface object
    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 configure struct elements of a struct type, use the addElement, getElement, and removeElement functions.

    In this example, the dictionary MyInterfaces.sldd contains one struct type.

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

    Get the struct type object using the getDataType function. The struct type object contains two struct element objects.

    structTypeObj = getDataType(archDataObj,"structType1")
    structTypeObj = 
    
      StructType with properties:
    
               Name: 'structType1'
        Description: ''
           Elements: [1×2 Simulink.dictionary.archdata.StructElement]
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    To create a struct element object and add it to the struct type, use the addElement function.

    structElemObj3 = addElement(structTypeObj,"structElement3")
    structElemObj3 = 
    
      StructElement with properties:
    
               Name: 'structElement3'
               Type: [1×1 Simulink.dictionary.archdata.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.dictionary.archdata.StructType]

    To access an existing function element, use the getElement function.

    structElemObj2 = getElement(structTypeObj,"structElement2")
    structElemObj2 = 
    
      StructElement with properties:
    
               Name: 'structElement2'
               Type: [1×1 Simulink.dictionary.archdata.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.dictionary.archdata.StructType]

    To remove a struct element from a struct type, use the removeElement function.

    removeElement(structTypeObj,"structElement1")

    The struct type object now contains only two struct elements, structElement2 and structElement3

    structTypeObj.Elements(1)
    ans = 
    
      StructElement with properties:
    
               Name: 'structElement2'
               Type: [1×1 Simulink.dictionary.archdata.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.dictionary.archdata.StructType]
    structTypeObj.Elements(2)
    ans = 
    
      StructElement with properties:
    
               Name: 'structElement3'
               Type: [1×1 Simulink.dictionary.archdata.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.dictionary.archdata.StructType]

    Version History

    Introduced in R2023b