Can I automatically convert a function from MATLAB or a toolbox into c++ code?

3 次查看(过去 30 天)
I did some image processing using matlab. Now I am re-writing my matlab code into to c++.
For some of the parts in my matlab code, I use built in MATLAB functions (from the image processing toolbox)such as bwlabel, regionprops, etc. My question is it possible to convert these functions into c++ code. Perhaps using mcc?
Is there any other technique to do so would be of great great help as I believe wriitng the c++ code of such continuos from scratch is a huge task it self.
  1 个评论
Jiro Doke
Jiro Doke 2011-4-9
Just to make sure we cover all venues, do you actually need C++ code? Or do you need to integrate your MATLAB program into your C++ program? With MATLAB Compiler (mcc), you can create stand alone C++ shared libraries:
http://www.mathworks.com/help/toolbox/compiler/f2-995712.html

请先登录,再进行评论。

采纳的回答

Arnaud Miege
Arnaud Miege 2011-4-5
You can use Embedded MATLAB to generate C/C++ code, provided that you restrict yourself to using the Embedded MATLAB Subset.
Note that you will need to have a license of Simulink, Real-Time Workshop and probably also Real-Time Workshop Embedded Coder (for the C++ part). As far as I know, it only generates encapsulated C++, i.e. no classes. For more info see the documentation on Converting MATLAB Code to C/C++ Code.
You may want to contact MathWorks for more information.
HTH,
Arnaud
  1 个评论
Arnaud Miege
Arnaud Miege 2011-4-8
Slight update: in R2011a, you can now use MATLAB Coder to generate C/C++ code directly from MATLAB without the need for Simulink or Simulink Coder (new name for Real-Time Workshop).
http://www.mathworks.co.uk/products/new_products/latest_features.html
Arnaud

请先登录,再进行评论。

更多回答(3 个)

Walter Roberson
Walter Roberson 2011-3-31
No, there is no Mathworks-provided way to convert that code to C++ except to make calls back to MATLAB . You will have to write your own copies of the routines.
  1 个评论
Arnaud Miege
Arnaud Miege 2011-4-9
Actually, that's not quite true. You can use Embeddec MATLAB, and now MATLAB Coder in R2011a, as long as you restrict yourself to the subset of the MATLAB language that supports code generation, as I pointedout in my answer.

请先登录,再进行评论。


Ernur
Ernur 2011-3-31
You can look into MEX-files, http://www.mathworks.com/support/tech-notes/1600/1605.html. mexCallMATLAB(...) function in particular... In my opinion, it would be more time efficient than writing those functions yourself, especially if you will not use them on a regular basis.
Ernur
P.S.: If you need to use Simulink and have S-functions involved, you can use the same function to call Matlab.

bhavin
bhavin 2011-4-4
ok thanks for th info...will look into that..

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by