Main Content

addEntry

Class: Simulink.data.dictionary.Section
Package: Simulink.data.dictionary

Add new entry to data dictionary section

Syntax

addEntry(sectionObj,entryName,entryValue)
entryObj = addEntry(sectionObj,entryName,entryValue)

Description

addEntry(sectionObj,entryName,entryValue) adds an entry, with name entryName and value entryValue, to the data dictionary section sectionObj, a Simulink.data.dictionary.Section object.

entryObj = addEntry(sectionObj,entryName,entryValue) returns a Simulink.data.dictionary.Entry object representing the newly added data dictionary entry.

Input Arguments

expand all

Target data dictionary section, specified as a Simulink.data.dictionary.Section object. Before you use this function, represent the target section with a Simulink.data.dictionary.Section object by using, for example, the getSection function.

Name of new data dictionary entry, specified as a character vector.

Example: 'myNewEntry'

Data Types: char

Value of new data dictionary entry, specified as a MATLAB expression that returns any valid data dictionary content.

Example: 27.5

Example: myBaseWorkspaceVariable

Example: Simulink.Parameter

Examples

expand all

Represent the Design Data section of the data dictionary myDictionary_ex_API.sldd with a Simulink.data.dictionary.Section object named dDataSectObj.

myDictionaryObj = Simulink.data.dictionary.open('myDictionary_ex_API.sldd');
dDataSectObj = getSection(myDictionaryObj,'Design Data');

Add an entry to the Design Data section of myDictionary_ex_API.sldd an entry myNewEntry with value 237.

addEntry(dDataSectObj,'myNewEntry',237)

Represent the Design Data section of the data dictionary myDictionary_ex_API.sldd with a Simulink.data.dictionary.Section object named dDataSectObj.

myDictionaryObj = Simulink.data.dictionary.open('myDictionary_ex_API.sldd');
dDataSectObj = getSection(myDictionaryObj,'Design Data');

Add an entry to the Design Data section of myDictionary_ex_API.sldd. Name the new entry myNewParam and assign a Simulink.Parameter object to the value.

addEntry(dDataSectObj,'myNewParam',Simulink.Parameter)

The expression Simulink.Parameter constructs a new Simulink.Parameter object, and the addEntry function assigns the object to the value of the new data dictionary entry myNewParam.

Tips

  • addEntry returns an error if the entry name you specify with entryName is already the name of an entry in the target data dictionary section or in the same section of any referenced dictionaries.

Alternatives

You can use Model Explorer to add entries to a data dictionary in the same way you can use it to add variables to a model workspace or the base workspace.

Introduced in R2015a