Main Content

destroy

Destroy data element and remove from data interface

Since R2022b

    Description

    example

    destroy(dataElementObj) destroys the data element dataElementObj and removes it from its parent Simulink.interface.dictionary.DataInterface object.

    Examples

    collapse all

    This example shows how to delete a data element and remove it from a data interface.

    Create a Simulink.interface.Dictionary object by opening an existing interface dictionary.

    interfaceDictObj = Simulink.interface.dictionary.open('myInterfaceDict.sldd')
    interfaceDictObj = 
      Dictionary with properties:
    
        DictionaryFileName: 'myInterfaceDict.sldd'
                Interfaces: [1×1 Simulink.interface.dictionary.DataInterface]
                 DataTypes: [0×0 Simulink.interface.dictionary.DataType]

    This interface dictionary has one data interface definition. The data interface has two data elements.

    interfaceObj = interfaceDictObj.Interfaces
    interfaceObj = 
      DataInterface with properties:
    
               Name: 'interface1'
        Description: ''
           Elements: [1×2 Simulink.interface.dictionary.DataElement]
              Owner: [1×1 Simulink.interface.Dictionary]
    
    

    Use the getElement function to access a data element.

    dataElem1 = getElement(interfaceObj,'element1')
    dataElem1 = 
    
      DataElement with properties:
    
               Name: 'element1'
               Type: [1×1 Simulink.interface.dictionary.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.interface.dictionary.DataInterface]

    Use the destroy function to delete the data element and remove it from the data interface.

    destroy(dataElem1)
    interfaceObj
    interfaceObj = 
    
      DataInterface with properties:
    
               Name: 'interface1'
        Description: ''
           Elements: [1×1 Simulink.interface.dictionary.DataElement]
              Owner: [1×1 Simulink.interface.Dictionary]

    The data interface, interfaceObj now has only one data element.

    Input Arguments

    collapse all

    Data element to destroy, specified as a Simulink.interface.dictionary.DataElement object.

    Version History

    Introduced in R2022b

    expand all