Main Content

evalin

Evaluate MATLAB expression in data dictionary section

Description

returnValue = evalin(sectionObj,expression) evaluates a MATLAB® expression in the data dictionary section sectionObj and returns the values returned by expression.

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

Execute the whos command in the Design Data section of myDictionary_ex_API.sldd.

evalin(dDataSectObj,'whos')
   Name                 Size            Bytes  Class                 Attributes

  fuelFlow             1x1                 8  double                          
  myRefEntry           1x1                 1  logical                         
  parameterGain37      1x1               112  Simulink.Parameter              

Input Arguments

collapse 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.

MATLAB expression to evaluate, specified as a character vector.

Example: 'a = 5.3'

Example: 'whos'

Example: 'CurrentSpeed.Value = 290.73'

Data Types: char

Limitations

  • Use of evalin with data dictionaries is discouraged. Instead use the getValue function to return the value of a data dictionary entry.

  • Only certain MATLAB functions can be used as the expression to be evaluated by evalin: who, whose, exist, save, and clear.

  • evalin cannot be used in a script to read data dictionary variables.

  • evalin can evaluate an enumeration variable, but not an enumeration type.

Tips

  • evalin allows you to treat a data dictionary section as a MATLAB workspace. You can think of entries contained in the section as workspace variables you can manipulate with MATLAB expressions.

Version History

Introduced in R2015a