Products & Services Industries Academia Support User Community Company

Learn more about MATLAB   

mexPutVariable (C and Fortran) - Copy mxArray from MEX-function into specified workspace

C Syntax

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

Fortran Syntax

integer*4 mexPutVariable(workspace, varname, pm)
character*(*) workspace, varname
mwPointer pm

Arguments

workspace

Specifies the scope of the array that you are copying. The possible values are

base

Copy mxArray to the base workspace.

caller

Copy mxArray to the caller's workspace.

global

Copy mxArray to the list of global variables.

varname

Name given to the mxArray in the workspace

pm

Pointer to the mxArray

Returns

0 on success; 1 on failure. A possible cause of failure is that pm is NULL in C (0 in Fortran).

Description

Call mexPutVariable to copy the mxArray, at pointer pm, from your MEX-function into the specified workspace. MATLAB software gives the name, varname, to the copied mxArray in the receiving workspace.

mexPutVariable makes the array accessible to other entities, such as MATLAB, M-files, or other MEX-functions.

If a variable of the same name already exists in the specified workspace, mexPutVariable overwrites the previous contents of the variable with the contents of the new mxArray. For example, suppose the MATLAB workspace defines variable Peaches as:

Peaches
1     2     3     4

and you call mexPutVariable to copy Peaches into the same workspace:

mexPutVariable("base", "Peaches", pm)

Then the old value of Peaches disappears and is replaced by the value passed in by mexPutVariable.

C Examples

See mexgetarray.c in the matlabroot/extern/examples/mex folder .

See Also

mexGetVariable

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

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