compiling matlab code to dll to run on c++ aplication
조회 수: 12 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (1개)
Kaustubha Govind
2012년 4월 30일
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.
댓글 수: 1
Hadi Salimi
2020년 10월 9일
참고 항목
카테고리
Help Center 및 File Exchange에서 C Shared Library Integration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!