Main Content

Simulink.data.existsInGlobal

Determine if variable exists in context of Simulink model

Description

tf = Simulink.data.existsInGlobal(modelName,varName) determine if the variable varName exists in the context of the Simulink® model modelName. Simulink.data.existsInGlobal searches the Design Data section of the data dictionary and MAT files linked to the model as external data sources, or the MATLAB® base workspace if the model is not linked to any external data sources.

example

Examples

collapse all

Determine if the variable PressVect exists in the context of the Simulink model vdp.slx, which has no external data sources.

openExample('simulink_general/VanDerPolOscillatorExample')
Simulink.data.existsInGlobal('vdp','PressVect')
ans =

logical
     0

Determine if the variable myNewVar exists in the context of the Simulink model BasicModellingData.slx, which is linked to the MAT file BasicModellingDataDefinitions.mat.

openExample('BasicModellingData')
Simulink.data.existsInGlobal('BasicModellingData','myNewVar')
ans =

logical
     0

Determine if the variable PressVect exists in the context of the Simulink model sldemo_fuelsys_dd_controller.slx, which is linked to the data dictionary sldemo_fuelsys_dd_controller.sldd.

Open the model sldemo_fuelsys_dd_controller from the example Using a Data Dictionary to Manage the Data for a Fuel Control System.

openExample('simulink_automotive/UseDDForFuelContSysExample')
sldemo_fuelsys_dd_controller
Simulink.data.existsInGlobal('sldemo_fuelsys_dd_controller','PressVect')

ans =

logical
     1

Input Arguments

collapse all

Model name, specified as a character vector or a string.

Example: 'myTestModel'

Data Types: char | string

Name of the variable, specified as a character vector or a string.

Example: 'myTargetVariable'

Data Types: char | string

Output Arguments

collapse all

True or false result, returned as 1 or 0 of data type logical.

Alternatives

You can use Model Explorer to search for the variables.

Version History

Introduced in R2015a