Documentation

Simulink.data.existsInGlobal

Check existence of variable in context of Simulink model

Syntax

varExists = Simulink.data.existsInGlobal(modelName,varName)

Description

example

varExists = Simulink.data.existsInGlobal(modelName,varName) returns an indication of the existence of a variable or data dictionary entry varName in the context of the Simulink model modelName. Simulink.data.existsInGlobal searches the Design Data section of the data dictionary that is linked to the target model or the MATLAB base workspace if the target model is not linked to any data dictionary.

Examples

collapse all

Determine the existence of a variable PressVect in the context of the Simulink model vdp.slx, which is not linked to any data dictionary.

Simulink.data.existsInGlobal('vdp','PressVect')
ans =

     0

Because vdp.slx is not linked to any data dictionary, existsInGlobal searches only in the MATLAB base workspace for PressVect.

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

Simulink.data.existsInGlobal('sldemo_fuelsys_dd_controller','PressVect')
ans =

     1

Because sldemo_fuelsys_dd_controller.slx is linked to the data dictionary sldemo_fuelsys_dd_controller.sldd , existsInGlobal searches for PressVect only in the Design Data section of the dictionary.

Input Arguments

collapse all

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

Example: 'myTestModel'

Data Types: char

Name of target variable or data dictionary entry, specified as a character vector.

Example: 'myTargetVariable'

Data Types: char

Output Arguments

collapse all

Indication of existence of target variable or data dictionary entry, returned as 1 to indicate existence or 0 to indicate absence.

Tips

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

Alternatives

You can use Model Explorer to search a data dictionary or any workspace for entries or variables.

Introduced in R2015a

Was this topic helpful?