Main Content

mexGetVariable (C)

Copy of variable from specified workspace

C Syntax

#include "mex.h" mxArray *mexGetVariable(const char *workspace, const char *varname);

Description

Note

To write MEX functions using modern C++ features and theMATLAB Data API for C++, seeWrite C++ Functions Callable from MATLAB (MEX Files).

CallmexGetVariableto get a copy of the specified variable. The returnedmxArray包含的所有数据的副本和特点s that the variable had in the other workspace. Modifications to the returnedmxArraydo not affect the variable in the workspace unless you write the copy back to the workspace withmexPutVariable.

UsemxDestroyArrayto destroy themxArraycreated by this routine when you are finished with it.

Input Arguments

expand all

WorkspacemexGetVariablesearches forvarname, specified asconst char*. The possible values are:

base

Search for the variable in the base workspace.

caller

Search for the variable in the caller workspace.

global

Search for the variable in the global workspace.

Name of the variable to copy, specified asconst char*.

Output Arguments

expand all

Copy of variable, specified asmxArray*. The function returnsNULLon failure. A common cause of failure is specifying a variable that is not currently in the workspace. Perhaps the variable was in the workspace at one time but has since been cleared.

Examples

See these examples inmatlabroot/extern/examples/mex:

Version History

Introduced before R2006a