Main Content

setValue

Set value of data dictionary entry

Description

setValue(entryObj,newValue) assigns the value newValue to the data dictionary entry entryObj, a Simulink.data.dictionary.Entry object.

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.

example

Examples

collapse all

Represent the data dictionary entry fuelFlow with a Simulink.data.dictionary.Entry object named fuelFlowObj. fuelFlow is defined in the data dictionary myDictionary_ex_API.sldd.

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

Set the value of the entry fuelFlow to 493. Then, view the Value property of fuelFlowObj to observe the change.

setValue(fuelFlowObj,493)
fuelFlowObj
fuelFlowObj = 

  Entry with properties:

              Name: 'fuelFlow'
             Value: 493
        DataSource: 'myDictionary_ex_API.sldd'
      LastModified: '2014-Sep-05 13:37:22.161124'
    LastModifiedBy: 'jsmith'
            Status: 'Modified'

Input Arguments

collapse all

Target data dictionary entry, specified as a Simulink.data.dictionary.Entry object. Before you use this function, represent the target entry with a Simulink.data.dictionary.Entry object by using, for example, the getEntry function.

Value to assign to data dictionary entry, specified as a MATLAB expression. The expression must return a value that is supported by the data dictionary section that contains the entry.

Example: 27.5

Example: myBaseWorkspaceVariable

Example: Simulink.Parameter

Alternatives

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

Version History

Introduced in R2015a