laura
laura

Reputation: 165

convert matlab code to c code

is there s a way to convert simulink blocks or a matlab ".m" code to C code automatically ?

Upvotes: 3

Views: 6040

Answers (2)

yuk
yuk

Reputation: 19880

To convert Simulink models or MATLAB m-code to C you need Real-Time Workshop. It supports only subset of MATLAB language and oriented for embedded systems.

Look also at other MatWorks products for code generation and application deployment: http://www.mathworks.com/products

With MATLAB Compiler you will not get a C code, but a binary code, executable or library (dll), which will run on machines without MATLAB installed, but with MATLAB Compiler Runtime (MCR) library. It quite large in size, and platform specific and I believe it has to match the MATLAB version of compiled code.

For the new coming release 2011a The MathWorks developed new code generation products: MATLAB Coder, Simulink Coder and Embedded Coder.

Upvotes: 2

phooji
phooji

Reputation: 10395

I'm not aware of any direct translation tool, but there are a few alternatives:

  1. Matlab Compiler will let you create a shared library (callable from C code) from your .m code.
  2. GNU Octave is an open source interpreter that has many of the same functions as Matlab. It is open source, and written in C. You might feasibly build a C library based on on this, although it would be a lot more heavy-weight than option (1).

Upvotes: 3

Related Questions