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

4 Ansichten (letzte 30 Tage)
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 Kommentar
Jiro Doke
Jiro Doke am 9 Apr. 2011
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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Arnaud Miege
Arnaud Miege am 5 Apr. 2011
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 Kommentar
Arnaud Miege
Arnaud Miege am 8 Apr. 2011
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (3)

Walter Roberson
Walter Roberson am 31 Mär. 2011
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 Kommentar
Arnaud Miege
Arnaud Miege am 9 Apr. 2011
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.

Melden Sie sich an, um zu kommentieren.


Ernur
Ernur am 31 Mär. 2011
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 am 4 Apr. 2011
ok thanks for th info...will look into that..

Kategorien

Mehr zu Simulink Coder 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