Documentation Center

  • Trials
  • Product Updates

hasVariable

Determine if variable exists in workspace

Syntax

variableExists = hasVariable(workspaceHandle,variableName)
variableExists = workspaceHandle.hasVariable(variableName)

Description

variableExists = hasVariable(workspaceHandle,variableName) returns 1 if the variable exists in the workspace, and 0 if not.

variableExists = workspaceHandle.hasVariable(variableName) is an alternative syntax.

Input Arguments

workspaceHandle

Handle to the workspace.

variableName

Name of the variable.

Output Arguments

variableExists

Boolean value that indicates whether the variable exists in the workspace (1 if true and 0 if false).

Examples

Determine Existence of Variable

Determine if the variable K exists in the workspace for model mdl.

wksp = get_param(mdl,‘ModelWorkspace')
exists = wksp.hasVariable('K')
exists =
   1

See Also

Was this topic helpful?