Call MATLAB API in C / C ++

I just heard from somewhere that for numerical computation "MATLAB does offer some convenient APIs. If you call these APIs in your C / C ++ code, you can speed up the computation significantly."

But I did not find such information in MATLAB docs, for example http://www.mathworks.com/support/tech-notes/1600/1622.html and http://www.mathworks.com/access/helpdesk/help /techdoc/matlab_external/bp_kqh7.html . All that I learned on these websites is that MATLAB can be called in C and C ++ using the Matlab mechanism or by compiling M files into libraries using mcc. They do not mention MATLAB's built-in numeric APIs that can be called in C / C ++.

Can anyone clarify?

Thank you and welcome!

+4
source share
3 answers

You need the "Engine" routines. This allows you to start the MATLAB background process with C and perform calculations on it: relevant MATLAB documentation .

This works very well, take a look at the examples. I would say that the most annoying thing that it works is data marshaling between C and MATLAB. But it is always a problem when doing this kind of thing.

+4
source

It looks like you're looking for tools for creating code in the Matlab built-in toolbox or in real time.

Make a doc eml and find the demo version of LMS (Least Square).

The code generator is not bad, it will give you a make file that will create a static library. It is easy to use with your standalone C / C ++ code.

0
source

There may be a few things the link is quoting, I assume this applies to the MATLAB Compiler . So, by going from MATLAB → C ++, you can use the compiler to create standalone "fast" applications. However, when speed testing improved, I noticed that this was negligible. Honestly, you are probably much better at coding your work in C with get-go, the code that the compiler generates is spaghetti and non-object. I should also mention that this is an expensive extension for Matlab.

You can use MCR in your own C ++ project as a standalone library ( details ) ... but you can get similar results using Numerical Recipes .

Disclaimer: I used this product 2-3 years ago, now everything may be different.

0
source

All Articles