Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert matlab code to c code

Tags:

matlab

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

like image 859
laura Avatar asked Jan 27 '26 04:01

laura


2 Answers

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).
like image 130
phooji Avatar answered Jan 30 '26 01:01

phooji


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.

like image 20
yuk Avatar answered Jan 30 '26 01:01

yuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!