compiling matlab code to dll to run on c++ aplication

4 Ansichten (letzte 30 Tage)
Rui
Rui am 27 Apr. 2012
Kommentiert: Hadi Salimi am 9 Okt. 2020
hi there,
i have a signal process algorithm written in matlab that runs on a c++ aplication as a compiled exe by matlab compiler.
in order to increase performance i would like to convert the matlab algorithm to C++ language, so that it could run natively on a C++ application, without the need of matlab runtime compiler (MCR).
2 questions: is this possible? how's the performance of matlab compiled dll compared to matlab compiled standalone exe? and to native c++?
i´m avoiding re-writing the algorithm in c++ as it would be quiet a time-consuming task.
thanks!

Antworten (1)

Kaustubha Govind
Kaustubha Govind am 30 Apr. 2012
You can generate standalone C code from your MATLAB functions using MATLAB Coder - the generated code does not rely on the MCR and performance should be comparable to native code.
AFAIK, MATLAB Compiler shared libraries and standalones should have similar performance, and should be equivalent to running the code in MATLAB (including MATLAB startup and exit time).
However, note that some math operations are highly optimized in MATLAB (use of BLAS routines, multithreading, etc.), so it is possible that the MATLAB Compiler produced binaries are faster than the native code generated using MATLAB Coder. I would recommend getting a demo license for MATLAB Coder to see if you get better performance for your code.
Also, note that to use MATLAB Coder, you are restricted to a subset of the MATLAB language/functions that are supported for code-generation. If you are using functions outside this subset, then MATLAB Compiler is your only alternative to re-writing the algorithm by hand.

Kategorien

Mehr zu C Shared Library Integration finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by