How to use mexPrintf with C++ MEX Functions
Mostrar comentarios más antiguos
Hi there
I am testing the new C++ MEX API with Matlab 2018b. However, when try to use mexPrintf, I found that it is only defined in mex.h but not mex.hpp. Include mex.hpp and mex.h in the same time is not allowed in mex function. Is there any other ways to use mexPrinft or print out something in matlab command windows if C++ MEX API is used?
A simple example for testing is attached below. If #include <mex.h> is uncommented, compilation will fail.
#include <mex.hpp>
#include <mexAdapter.hpp>
//#include <mex.h>
using namespace matlab::data;
using matlab::mex::ArgumentList;
class MexFunction : public matlab::mex::Function
{
public:
void operator()(ArgumentList outputs, ArgumentList inputs)
{
const double offSet = inputs[0][0];
TypedArray<double> doubleArray = std::move(inputs[1]);
for (auto& elem : doubleArray)
{
elem += 1*offSet;
}
outputs[0] = doubleArray;
//mexPrintf("Hello");
}
};
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!