This change has been incorporated into the documentation in Release 2011a (R2011a). For previous releases, read below for any additional information:
You can debug MATLAB code by saving the workspace as you enter your MATLAB code and then later using that workspace to debug your code.
For example, you might have the following function:
You can change it to:
You can then call myfcn from your MATLAB Engine application using engEvalString after putting a variable into MATLAB using engPutVariable.
For example, in your C code you might have:
engPutVariable(ep, "aVar", myCmxArray);
myCmxArrayResult = engGetVariable(ep,"result");
While examining the results of myCmxArrayResult, you might find that the result is not what you expect. Since you saved the workspace as you entered your function, you can now open MATLAB and load the saved workspace to see what data came into your function. You can then debug your function if needed from inside MATLAB.
You can do this by starting MATLAB and then loading the resulting debug_myfcn.MAT-file (which has x defined in it):
If x is different from what you expect, you know that most likely you created the mxArray myCmxArray incorrectly. If x is what you expect, you could set a breakpoint in myfcn and then debug it by calling: