Yes, mexPrintf
is what you need. But note that the command window does not forcibly flush the buffer it uses, often resulting in very long delays before your message is printed. This happens if you begin heavy computations after calling mexPrintf
.
A workaround is to use
mexEvalString("drawnow;")
after each call to mexPrintf
.
If you find that unappealing, you can make a macro that calls both:
#define printfFnc(...) { mexPrintf(__VA_ARGS__); mexEvalString("drawnow;");}
This uses the variadic macro __VA_ARGS__
. It may not be a part of a standard, but seems to be in GCC and Visual C++. Just call printfFnc
like you would call printf
(or mexPrintf
).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…