Main Content

Generate Reusable Code

With MATLAB®, you can generate reusable code in the following ways:

  • Write reusable functions using standard MATLAB function file names which you can call from different locations, for example, in a Simulink® model or MATLAB function library.

  • Compile external functions on the MATLAB path and integrate them into generated C code for embedded targets.

See Resolution of Function Calls for Code Generation (MATLAB Coder).

Common applications include:

  • Overriding generated library function with a custom implementation.

  • Implementing a reusable library on top of standard library functions that can be used with Simulink.

  • Swapping between different implementations of the same function.