Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab to C or C++

Tags:

I am working on an image processing project using Matlab. We should run our program (intended to be an application) on a cell phone.We were then asked to convert our code into C or C++ language so we get a feel of how long it would take for execution and then choose a platform. So far we didn't figure out how to do this conversion.. Any ideas of what to do to convert Matlab to C or C++??

like image 428
emma Avatar asked Nov 12 '10 16:11

emma


People also ask

Can I convert MATLAB code to C?

To convert MATLAB® Code to fixed-point C Code using the MATLAB Coder™ app: Open the MATLAB Coder app. On the Select Source Files page, add the entry-point function from which you want to generate code. Set Numeric Conversion to Convert to fixed point .

Does MATLAB use C or C++?

You can use MATLAB algorithms in your C and C++ applications. The MATLAB Engine API for C and C++ enables your applications to use and modify variables in the MATLAB workspace, call MATLAB functions, and evaluate MATLAB commands.

Is MATLAB better than C?

C++ simulations show superior performance like 100x better in time complexity than an equivalent MATLAB implementation. The code in C++ most of the times, is pretty much serial and no hi-fi optimization is done explicitly. Whereas, as per my awareness, MATLAB inherently does a lot of optimization.

What is C C command in MATLAB?

With pass by value, C code can return only a single scalar variable. With pass by reference, C code can return multiple variables, including arrays. Consider the MATLAB function adderRef . This function uses external C code to add two arrays. The coder.


1 Answers

The first thing you need to realise is that porting code from one language to another (especially languages as different as Matlab and C++) is generally non-trivial and time-consuming. You need to know both languages well, and you need to have similar facilities available in both. In the case of Matlab and C++, Matlab gives you a lot of stuff that you just won't have available in C++ without using libraries. So the first thing to do is identify which libraries you're going to need to use in C++. (You can write some of the stuff yourself, but you'll be there a long time if you write all of it yourself.)

If you're doing image processing, I highly recommend looking into something like ITK at http://www.itk.org -- I've written my image processing software twice in C++, once without ITK (coding everything myself) and once with, and the version that used ITK was finished faster, performed better and was ten times more fun to work on. FWIW.

like image 55
Stuart Golodetz Avatar answered Nov 11 '22 04:11

Stuart Golodetz