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.

mexGetVariablePtr (C and Fortran)

Read-only pointer to variable from another workspace

C Syntax

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

Fortran Syntax

#include "fintrf.h"
mwPointer mexGetVariablePtr(workspace, varname)
character*(*) workspace, varname



Specifies which workspace you want mexGetVariablePtr to search. The possible values are:


Search for the variable in the base workspace.


Search for the variable in the caller workspace.


Search for the variable in the global workspace.


Name of a variable in another workspace. This is a variable name, not an mxArray pointer.


Read-only pointer to the mxArray on success. Returns NULL in C (0 in Fortran) on failure.


Call mexGetVariablePtr to get a read-only pointer to the specified variable, varname, into your MEX-file workspace. This command is useful for examining an mxArray's data and characteristics. If you want to change data or characteristics, use mexGetVariable (along with mexPutVariable) instead of mexGetVariablePtr.

If you simply want to examine data or characteristics, mexGetVariablePtr offers superior performance because the caller wants to pass only a pointer to the array.

Introduced before R2006a

Was this topic helpful?