I'm developing a MATLAB MEX-file (DLL) in C++ that I'm debugging with Visual Studio. I'm able to successfully step through the code but I'm having problems displaying the contents of certain variables (matrices).
Matrices are stored in contiguous blocks of memory float[N]
or double[N]
where N
is a template parameter (N
is known at compile time).
I need to control the precision of the formatting of the numbers in the matrices, and I'd also like the elements formatting a particular way (so they can easily be entered back in to MATLAB for comparison) so I wrote a quick printMat
function to convert the matrix to a string. I then call this function in the immediate window when I want to inspect the contents of a matrix.
My problem: The immediate window only displays part of the string e.g.
"[ -1.0737417600000000e+08, -1.0737417600000000e+08, -1.0737417600000000e+08; -1.0737417600000000e+08, -1.0737417600000000e+08, -1.0737417600000000e+08; -1.0737417600000000e+08, -1.0737417600000000e+08...
This string should actually be.
"[ -1.0737417600000000e+08, -1.0737417600000000e+08, -1.0737417600000000e+08; -1.0737417600000000e+08, -1.0737417600000000e+08, -1.0737417600000000e+08; -1.0737417600000000e+08, -1.0737417600000000e+08, -1.0737417600000000e+08]"
I can see the entire string if the matrix is smaller but that's just not an option in my case.
What I've tried so far :
- Printing to
std::cout
- Printing to
std::cerr
Unfortunately nothing displays on cout
or cerr
my guess is they are controlled by the MATLAB process and won't print anything until the debugger "releases" the process.
My question:
Is there a way to get an unadulterated version of this string from the immediate window? I really don't want to litter my code with print statements or temporary debugging string since that will require a rebuild each time I want to inspect the value of a new variable.