Main Content

convertToStructType

Convert data interface to struct type object

Since R2023b

    Description

    example

    StructTypeObj = convertToStructType(dataInterfaceObj) converts the data interface object interfaceObj to a Simulink.dictionary.archdata.StructType object.

    Examples

    collapse all

    To convert a data interface to a struct type in a data dictionary, use the convertToStructType function.

    In this example, the dictionary MyInterfaces.sldd contains one data interface.

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

    The data interface contains two data elements.

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

    To convert the data interface to a struct type, use the convertToStructType function.

    structTypeObj = convertToStructType(dataInterfaceObj)
    
    structTypeObj = 
    
      StructType with properties:
    
               Name: 'DataInterface1'
        Description: ''
           Elements: [1×2 Simulink.dictionary.archdata.StructElement]
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    The output struct type contains two struct elements corresponding to the two data elements of the input data interface.

    The architectural data object now contains no data interfaces, and one struct type.

    archDataObj
    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]

    Input Arguments

    collapse all

    Data interface object, specified as a Simulink.dictionary.archdata.DataInterface object.

    Output Arguments

    collapse all

    Struct type object, returned as a Simulink.dictionary.archdata.StructType object. The structure type object contains StructElement objects that are equivalent to the DataElement objects contained in the input data interface object, dataInterfaceObj.

    Version History

    Introduced in R2023b