Documentation

Simulink.data.evalinGlobal

Evaluate MATLAB expression in context of Simulink model

Syntax

returnValue = Simulink.data.evalinGlobal(modelName,expression)

Description

example

returnValue = Simulink.data.evalinGlobal(modelName,expression) evaluates the MATLAB expression expression in the context of the Simulink model modelName and returns the values returned by expression. evalinGlobal evaluates expression in the Design Data section of the data dictionary that is linked to the target model or in the MATLAB base workspace if the target model is not linked to any data dictionary.

Examples

collapse all

Evaluate the MATLAB expression myNewVariable = 237; in the context of the model vdp, which is not linked to any data dictionary. myNewVariable appears as a variable in the MATLAB base workspace.

Simulink.data.evalinGlobal('vdp','myNewVariable = 237;')

Evaluate the MATLAB expression myNewEntry = true; in the context of the model sldemo_fuelsys_dd_controller, which is linked to the data dictionary sldemo_fuelsys_dd_controller.sldd. myNewEntry appears as an entry in the Design Data section of the dictionary.

Simulink.data.evalinGlobal('sldemo_fuelsys_dd_controller',...
'myNewEntry = true;')

Confirm the creation of the entry myNewEntry in the data dictionary sldemo_fuelsys_dd_controller.sldd by viewing the dictionary in Model Explorer.

myDictionaryObj = Simulink.data.dictionary.open(...
'sldemo_fuelsys_dd_controller.sldd');
show(myDictionaryObj)

Input Arguments

collapse all

Name of target Simulink model, specified as a character vector.

Example: 'myTestModel'

Data Types: char

MATLAB expression to evaluate, specified as a character vector.

Example: 'a = 5.3'

Example: 'whos'

Example: 'CurrentSpeed.Value = 290.73'

Data Types: char

Output Arguments

collapse all

Value returned by the specified MATLAB expression.

Tips

  • evalinGlobal helps you transition Simulink models to the use of data dictionaries. You can use the function to manipulate model variables before and after linking a model to a data dictionary.

Introduced in R2015a

Was this topic helpful?