Embedded software developers have long relied on MATLAB® for algorithm design and prototyping and on C code for implementation on embedded processors and DSPs. As a high-level language, MATLAB facilitates design exploration. In contrast, programming in C is well suited to optimizing DSPs for performance, memory, and processing power. The challenge is to transition a design from the flexible development environment of MATLAB to the constrained programming style of C. The solution is automatic translation of MATLAB to embeddable C
Manually translating MATLAB to C involves incorporating into the code low-level details such as data-type assignments, memory allocations, and optimizations for computational load and memory. A great deal of effort is required to ensure that the MATLAB code and the C code remain equivalent.
When your MATLAB algorithm uses the Embedded MATLAB™ language subset, the translation to C becomes unambiguous, enabling you to focus on refining your design rather than producing and verifying hand written C code
This article outlines the challenges involved in the manual translation from MATLAB to C, demonstrates how to use the Embedded MATLAB subset for automatic translation, and provides best practices for coding your MATLAB algorithm to improve the generated C code
By Houman Zarrinkoub and Grant Martin
This article was published in MATLAB Digest, November 2009