How to transform MATLAB code into C++ code.
When you compile matlab code using
mcc (by default or when using the
-m option), you get an executable. So from your C++ file, you can call the matlab executable with the C/C++ command
If you use the
-l option (using
mcc), you get a shared library, and header. For instance if you type (in matlab):
This should produce a shared library
test.so, and a header
test.h you should have line similar to that:
bool MW_CALL_CONV mlxTest(int nlhs, mxArray *plhs, int nrhs, mxArray *prhs);
You can call your matlab function using that.
In addition you have to add both shared libraries and headers in you msvc project.