mex script and how to show output from another function which is using vprintf()

조회 수: 6 (최근 30일)
Hi, I am implementing a mex script, where at some point I need to call a function from an external library. This function is as simple as printing the provided input, which is though collected as arguments and passed to vprintf(). See below:
void PrintInfo(const char *format, ...)
{
va_list args;
va_start(args, format);
vprintf(format, args);
va_end(args);
}
The issue now is that once I call the PrintInfo() function inside my mex script for example:
PrintInfo("Vector size is: %i \n", myVec.size());
I am not able to get any output in the matlab's console prompt, like I do when I use printf() or cout instead. Does someone has any idea why is this happening.
Since it is not possible to alter the library's code, I would like to find a solution within the mex script.
Update: my working environment is windows if that makes any difference

채택된 답변

OCDER
OCDER 2018년 6월 6일
Instead of using vprintf, try using mexPrintf
  댓글 수: 13
ThT
ThT 2018년 6월 7일
@OCDER thanks for the example, it's not exactly for what I was hopping for but it seems to do the job. In any case it a workaround for sure. Thank you for your time.
OCDER
OCDER 2018년 6월 7일
You're welcome! Glad we can help to get a workaround at least.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by