Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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 = hasVariable(wksp,'K')
exists =
   1

See Also

Introduced in R2012a

Was this topic helpful?