Main Content

assignin

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

Assign value to data dictionary entry

Syntax

assignin(sectionObj,entryName,entryValue)

Description

assignin(sectionObj,entryName,entryValue) assigns the value entryValue to the data dictionary entry entryName in the data dictionary section sectionObj, a Simulink.data.dictionary.Section object. If an entry with the specified name is not in the target section, assignin creates the entry with the specified name and value.

If an entry with the name specified by input argument entryName is not defined in the target data dictionary section but is defined in a referenced dictionary, assignin does not create a new entry in the target section but operates on the entry in the referenced dictionary.

To programmatically access variables for the purpose of sweeping block parameter values, consider using Simulink.SimulationInput objects instead of modifying the variables through the programmatic interface of the data dictionary. See Optimize, Estimate, and Sweep Block Parameter Values.

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 target data dictionary entry, specified as a character vector. If a matching entry does not already exist, the functions creates a new entry using the specified name.

Example: 'myEntry'

Data Types: char

Value to assign to 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

Assign a value to a data dictionary entry by operating on a Simulink.data.dictionary.Section object.

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');

Assign the value 237 to an entry myAssignedEntry in the data dictionary myDictionary_ex_API.sldd. If an entry named myAssignedEntry is not in myDictionary_ex_API.sldd, create it.

assignin(dDataSectObj,'myAssignedEntry',237)

Alternatives

You can use the Model Explorer window to view and change the values of data dictionary entries.

Introduced in R2015a