engGetVariable (C)
Copy variable from MATLAB engine workspace
C Syntax
#include "engine.h" mxArray *engGetVariable(Engine *ep, const char *name);
Description
engGetVariable reads the named mxArray from
the MATLAB® engine session associated with ep.
The limit for the size of data transferred is 2 GB.
Use mxDestroyArray to destroy the mxArray
created by this routine when you are finished with it.
Note
The matlab::engine::MATLABEngine.getVariable function in the MATLAB Engine API for C++ is recommended over
engGetVariable. 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 engGetVariable or the Engine API for
C.
Input Arguments
Output Arguments
Examples
Read Variable in C Engine Application on Windows
This C code shows how to read a variable from a C engine application on a Windows® system.
The code first starts the MATLAB engine and then sends data to MATLAB for analysis and visualization. After performing eigenvalue
calculations, the code captures MATLAB output using engOutputBuffer and then copies the
eigenvalue mxArray variable from the MATLAB engine session using engGetVariable. The C code
then accesses and uses the copied eigenvalue data.
Read Variable in C Engine Application on Linux or macOS
This C code shows how to read a variable from a C engine application on a Linux® or macOS system.
The code first starts the MATLAB engine and then sends data to MATLAB for analysis and visualization. Next, the code uses the MATLAB engine to evaluate a string. The code captures MATLAB output using engOutputBuffer and then copies an
mxArray variable from the MATLAB engine session using engGetVariable. The C code
then accesses and uses the copied variable data.
Version History
Introduced before R2006a
