addElement
Description
creates a data element with the name dataElementObj
= addElement(dataInterfaceObj
,elementName
)elementName
and adds it to the
data interface specified by dataInterfaceObj
.
Examples
Add, Get, and Remove Data Element from Data Interface
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")
Input Arguments
dataInterfaceObj
— Data interface object
Simulink.dictionary.archdata.DataInterface
object
Data interface object, specified as a Simulink.dictionary.archdata.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.
Example: "myElement"
Output Arguments
dataElementObj
— Data element object
Simulink.dictionary.archdata.DataElement
object
Data element object, returned as a Simulink.dictionary.archdata.DataElement
object.
Version History
Introduced in R2023b
See Also
Tools
Objects
Simulink.dictionary.ArchitecturalData
|Simulink.dictionary.archdata.DataInterface
|Simulink.dictionary.archdata.DataElement
Functions
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)