Debug on Microsoft Windows Platforms
This example shows the general steps to debug yprime.c
, found in
your
folder. Refer to your Microsoft® documentation for specific information about using Visual Studio®. For an example, see How can I debug a MEX file on Microsoft Windows Platforms with Microsoft Visual
Studio 2017?matlabroot
/extern/examples/mex/
Make sure Visual Studio is your selected C compiler:
cc = mex.getCompilerConfigurations('C','Selected'); cc.Name
Compile the source MEX file with the
-g
option, which builds the file with debugging symbols included. For example:copyfile(fullfile(matlabroot,'extern','examples','mex','yprime.c'),'.','f') mex -g yprime.c
Start Visual Studio. Do not exit your MATLAB® session.
Refer to your Visual Studio documentation for information about attaching the MATLAB process.
Refer to your Visual Studio documentation for setting breakpoints in code.
Open MATLAB and type:
yprime(1,1:4)
yprime.c
is opened in the Visual Studio debugger at the first breakpoint.If you select Debug > Continue, MATLAB displays:
ans = 2.0000 8.9685 4.0000 -1.0947