Main Content

Modularize MATLAB Code

For large MATLAB® code, streamline code generation by modularizing the code:

  1. Break up your MATLAB code into smaller, self-contained sections.

  2. Save each section in a MATLAB function.

  3. Generate C/C++ code for each function.

  4. Call the generated C/C++ functions in sequence from a wrapper MATLAB function using coder.ceval.

  5. Generate C/C++ code for the wrapper function.

Besides streamlining code generation for the original MATLAB code, this approach also supplies you with C/C++ code for the individual sections. You can reuse the code for the individual sections later by integrating them with other generated C/C++ code using coder.ceval.