The mex function is an api that allows Matlab (i.e. the Matlab program) to call a function written in c / C ++. This function, in turn, can call Matlab's own functions. Thus, the mex function will be associated with the Matlab libraries. Thus, calling the mex function directly from a Python program without the Matlab libraries is not possible (and that makes no sense).
For reasons why the mex function was created in the first place? Should it be done for some non-matlab c libraries (or c-code) for Matlab users, or would it have to hide some proprietery matlab code code while still making it available to Matlab users? If this is the first case, then you can ask the owners of the mex function to provide it in a non-micro-dynamic form of lib, which you can include in another c or python program. This should be easy if the mex function is independent of Matlab's internal functions.
Others mentioned the matlab compiler ... yes, you can enable the mex function in standalone binary code that can be called from unix (thus, from python, but as a unix call) if you use the Matlab Compiler to create such a binary. This will require deploying the binary with the Matlab runtime. This is not quite the same as calling a function directly from python - for example, there are no return values.
ric0liva
source share