engPutVariable (C)
Put variable into MATLAB engine workspace
C Syntax
#include "engine.h" int engPutVariable(Engine *ep, const char *name, const mxArray *pm);
Description
engPutVariable writes mxArray
pm to the engine ep, giving it the variable name
name. The function returns 0 if successful and
1 if an error occurs.
If the mxArray does not exist in the workspace, the function
creates it. If an mxArray with the same name exists in the workspace,
the function replaces the existing mxArray with the new
mxArray.
The limit for the size of data transferred is 2 GB.
Do not use MATLAB® function names for variable names. Common variable names that conflict with
function names include i, j, mode, char, size, and path. To determine whether a particular name is associated with a MATLAB function, use the which function.
The engine application owns the original mxArray and is responsible
for freeing its memory. Although the engPutVariable function sends
a copy of the mxArray to the MATLAB engine workspace, the engine application does not need to account for or
free memory for the copy.
Note
The matlab::engine::MATLABEngine.setVariable function in the MATLAB Engine API for C++ is recommended over
engPutVariable. The MATLAB Engine API for C++ includes modern C++ features for writing engine
applications. For more information, see Call MATLAB from C++. There
are no plans to remove engPutVariable or the Engine API for
C.
Input Arguments
Examples
Put Variable into C Engine Workspace on Windows
This C code includes two examples of how to put a variable into the MATLAB engine workspace from a C engine application on a Windows® system.
Put Variable into C Engine Workspace on Linux or macOS
This C code includes two examples of how to put a variable into the MATLAB engine workspace from a C engine application on a Linux® or macOS system.
Version History
Introduced before R2006a
