1

When porting a complex MATLAB application to an embedded platform running native C, is the MATLAB-to-C code generation efficient and useful to get a (slow) starting point that I can then profile and optimize, or am I better off writing my application in C from scratch despite the added complexity of having to rewrite the entire code in C manually?

My concern is that MATLAB being vector-oriented, the generated C-code may just be so remote from how one would write code in C that I am just going to waste time trying to generate any code automatically and never actually use any of the generated code.

Lolo
  • 3,935
  • 5
  • 40
  • 50
  • Thanks. Indeed similar question with useful answer. It suggests that for a one-time conversion from MATLAB to C, and assuming I am not using some libraries off the beaten path, the MATLAB coder may be the way to go. Wondering if others will have a different take on it. – Lolo Dec 23 '14 at 07:51

1 Answers1

2

You will need both MATLAB Coder and Embedded Coder to customize and optimize the generated for the embedded target. I suggest you have a look for example at MATLAB to C Code Generation with Embedded MATLAB or other videos/webinars on the subject to get a better idea of what's involved.

am304
  • 13,758
  • 2
  • 22
  • 40
  • 1
    There is also a [documentation section](http://www.mathworks.com/help/coder/optimize-speed-of-generated-code.html) on optimizing performance of the generated code. Some suggestions are to edit your MATLAB code (e.g. loops are OK when generating code, or use `PARFOR` which translates to multi-threaded OpenMP code) and others suggest changing settings in the code generation project. – Ryan Livingston Dec 24 '14 at 12:41