How do I convert Octave code to C or C++ ?
-
I wish to run my Octave code on a Windows Embedded device. If there is no tool available for converting Octave, can I copy the code into MATLAB and use some tool to convert it to C or C++ ? How?
-
Answer:
There is a way to write wrappers for matlab so they work in C and C++, it is called the Matlab Engine http://www.mathworks.com/help/techdoc/matlab_external/f38569.html
Leon Palafox at Quora Visit the source
Other answers
There are at least 2 packages that can convert many Octave operations to C++: http://moby.ihme.washington.edu/bradbell/mat2cpp/mat2cpp.htm http://www.octave-compiler.org/ (dead link) https://strategoxt.org/Octave/WebHome Live, but many links are dead -- probably hasn't been updated since 2005 The former appears to be alive -- the author has made some changes recently; the latter appears to be dead or moved. The toolkit underneath the second project is still available and actively maintained.
Ken Meltsner
There is a MATLAB toolbox called Coders toolbox which could do the job for you. But this is licensed toolbox and you need to purchase it if not available already. Ublas tool as Ken mentioned is worth trying. One could also use http://arma.sourceforge.net/ library in native C/C++ to achieve the same functionalities and can be tweaked for performance as well.
Anumod Odungattu
The Octave/MATLAB language is very different from C and C++ in enough ways that it would be quite difficult to build a tool to convert from Octave code to sensible, efficient, human-readable C or C++. Fortunately, there are a couple of things that might work that you can try before undertaking to rewrite your code: First, try to compile Octave for your embedded platform. Even if this doesn't work at first, it may simply be an issue with the build system or an OS interaction feature that you might not need, so porting Octave enough to fulfill your needs might not be unreasonable. Second, look in to the Octave C++ integration features: http://en.wikipedia.org/wiki/GNU_Octave#C++_Integration http://wiki.octave.org/wiki.pl?CategoryExternal If these methods don't work, you may want to look into the MATLAB Compiler, which will let you compile MATLAB code into shared libraries. Watch out, though, because this will be expensive, x86 only, unsupported on an embedded OS, and you'll need to translate your code from Octave to MATLAB (though there are tools that can help with that).
Roy Xu
Related Q & A:
- How do I convert a PDF file to PDF/A in Delphi?Best solution by softwarerecs.stackexchange.com
- How do I convert a bitmap to vector?Best solution by Super User
- How Can I use .net dll in C program?Best solution by Stack Overflow
- How do I travel to Forest hill C.I by TTC from Dunn and Springhurst and get back?Best solution by Yahoo! Answers
- How do i isolate a in p=a+b+c?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.