tags:

views:

243

answers:

3

Hi,

I just heard from somewhere that for numerical computation, "Matlab does offer some user-friendly APIs. If you call these APIs in your C/C++ code, you can speed up computation dramatically."

But I did not find such information in Matlab documents like http://www.mathworks.com/support/tech-notes/1600/1622.html and http://www.mathworks.com/access/helpdesk/help/techdoc/matlab%5Fexternal/bp%5Fkqh7.html. All I learned from these websites is that Matlab can be called in C and C++ by Matlab engine or by compiling M-files into libraries by mcc. They don't mention any built-in numerical Matlab APIs that can be called in C C++.

Can someone please clarify?

Thanks and regards!

+1  A: 

You want the "Engine" routines. This allows you to start up a background MATLAB process from C and execute calculations on it: relevant MATLAB documentation.

It works pretty well, have a look at the examples. I would say the most annoying thing getting it working is marshaling the data between C and MATLAB. But that's always a problem when doing this kind of thing.

Adam Goode
A: 

It sounds like you're looking for the code generation tools in the embedded matlab toolbox or real time workshop.

Do doc eml and look for a the LMS (least mean square) equalizer demo.

The code generator is quite good, it will give you a make file that will build a static library. It's easy to use with your stand alone C/C++ code.

devin
A: 

There could be a few things that quote is referencing, I assume that it is referring to the Matlab Compiler. So going from Matlab -> C++ you can use the compiler to build standalone "faster" applications. However, when speed testing the improvement, I've noticed it to be negligible. Honestly, you're probably far better off coding your work in C from the get-go, the code that the compiler generates is spaghetti and non-object oriented. I should also mention that this is an expensive extension to Matlab.

You can use the MCR in your own c++ project as a stand-alone library (details)... but you might get similar results using Numerical Recipes.

** Disclaimer: I used this product 2-3 years ago, things could be different now. **

Ralphleon