addElement
Description
creates a dataElementObj
= addElement(dataInterfaceObj
,elementName
)Simulink.interface.dictionary.DataElement
object with the
specified name and adds it to the
Simulink.interface.dictionary.DataInterface
object
dataInterfaceObj
.
Examples
Add and Remove Data Elements From a Data Interface
This example shows how to access, add, and remove data elements from a data interface.
Open an existing interface dictionary. This creates a Simulink.interface.Dictionary
object, interfaceDictObj
.
interfaceDictObj = Simulink.interface.dictionary.open('myInterfaceDict.sldd')
interfaceDictObj = Dictionary with properties: DictionaryFileName: 'myInterfaceDict.sldd' Interfaces: [1x1 Simulink.interface.dictionary.DataInterface] DataTypes: [0x0 Simulink.interface.dictionary.DataType]
This interface dictionary contains one data interface definition.
interfaceObj = interfaceDictObj.Interfaces
interfaceObj = DataInterface with properties: Name: 'interface1' Description: '' Elements: [1x2 Simulink.interface.dictionary.DataElement] Owner: [1x1 Simulink.interface.Dictionary]
Data interfaces are composed of data elements which describe portions of a data interface. This interface definition contains two data elements.
interfaceObj.Elements(1)
ans = DataElement with properties: Name: 'element1' Type: [1x1 Simulink.interface.dictionary.ValueType] Description: '' Dimensions: '1' Owner: [1x1 Simulink.interface.dictionary.DataInterface]
interfaceObj.Elements(2)
ans = DataElement with properties: Name: 'element2' Type: [1x1 Simulink.interface.dictionary.ValueType] Description: '' Dimensions: '1' Owner: [1x1 Simulink.interface.dictionary.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: [1x1 Simulink.interface.dictionary.ValueType] Description: '' Dimensions: '1' Owner: [1x1 Simulink.interface.dictionary.DataInterface]
You can access an existing data element using the getElement
function.
dataElem3 = getElement(interfaceObj, 'element3')
dataElem3 = DataElement with properties: Name: 'element3' Type: [1x1 Simulink.interface.dictionary.ValueType] Description: '' Dimensions: '1' Owner: [1x1 Simulink.interface.dictionary.DataInterface]
Remove a data element from an interface using the removeElement
function.
removeElement(interfaceObj, 'element3')
Input Arguments
dataInterfaceObj
— Data interface to add element to
Simulink.interface.dictionary.DataInterface
object
Data interface to add element to, specified as a Simulink.interface.dictionary.DataInterface
object.
elementName
— Name of data element
character vector | string scalar
Name of data element to add to dataInterfaceObj
object, specified
as a character vector or string scalar.
Output Arguments
dataElementObj
— Data element object
Simulink.interface.dictionary.DataElement
object
Data element, returned as a Simulink.interface.dictionary.DataElement
object with the specified name,
and default property values.
Version History
Introduced in R2022b
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)