MATLAB: Can I use engGetVariable or mexGetVariable to retrieve objects in MATLAB 7.0 (R14)

cenggetvariableenginegetMATLABmexmexgetvariableobjectobjectsvariable

I am using MATLAB's C interface and would like to retrieve a variable that is a MATLAB object. However, when I use engGetVariable or mexGetVariable to retrieve one, an application error is thrown with the dialog:
The instruction at "0x78806af2" referenced memory at "0x000000040". The memory could not be "read".

Best Answer

The MATLAB C interface (MEX or MATLAB Engine) is unable to retrieve certain objects from the MATLAB workspace as we can't represent MATLAB objects outside the MATLAB process at this time. There is no way to get the object back into a C++ application outside of MATLAB.
As a workaround, you can call MATLAB code through Engine that queries property values on the object in MATLAB and returns strings or other primitive arrays back to the engine application.