mexGetVariable (C and Fortran)

Get copy of variable from specified workspace

C Syntax

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

Fortran Syntax

mwPointer mexGetVariable(workspace, varname)
character*(*) workspace, varname

Arguments

workspace

Specifies where mexGetVariable should search in order to find array varname. The possible values are

base

Search for the variable in the base workspace.

caller

Search for the variable in the caller's workspace.

global

Search for the variable in the global workspace.

varname

Name of the variable to copy

Returns

A copy of the variable on success. Returns NULL in C (0 on Fortran) on 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.

Description

Call mexGetVariable to get a copy of the specified variable. The returned mxArray contains a copy of all the data and characteristics that the variable had in the other workspace. Modifications to the returned mxArray do not affect the variable in the workspace unless you write the copy back to the workspace with mexPutVariable.

Use mxDestroyArray to destroy the mxArray created by this routine when you are finished with it.

C Examples

See mexgetarray.c in the mex subdirectory of the examples directory.

See Also

mexGetVariablePtr, mexPutVariable, mxDestroyArray

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS