Documentation Center

  • Trial Software
  • Product Updates

getVariable

Get value of variable from workspace

Syntax

variableValue = getVariable(workspaceHandle,variableName)
variableValue = workspaceHandle.getVariable(variableName)

Description

variableValue = getVariable(workspaceHandle,variableName) returns the value of the variable. If the variable does not exist in the workspace, an error occurs.

variableValue = workspaceHandle.getVariable(variableName) is an alternative syntax.

Input Arguments

workspaceHandle

Handle to the workspace containing the variable.

variableName

Name of the variable containing the value.

Output Arguments

variableValue

Value of the variable.

Examples

Get Value of Workspace Variable

Get the value of the workspace variable K, which is defined in model mdl.

wksp = get_param(mdl,'ModelWorkspace')
value = wksp.getVariable('K')
value =
   5

See Also

Was this topic helpful?