Main Content

Source Code Generation

Generate and verify source code modules

Learn how to initiate source code generation and learn about the files and folders that the code generator produces. To organize large projects, use the code generation project template. Projects help you find required files, manage and share files and settings, interact with source control, generate controller code, and run test harness simulations.

You can start with Generate Code by Using the Quick Start Tool.


Simulink CoderGenerate and execute C and C++ code from Simulink models, Stateflow charts, and MATLAB functions for use in applications such as simulation acceleration, rapid prototyping, and hardware-in-the-loop (HIL) simulations (Since R2019b)


expand all

slbuildBuild standalone executable file or model reference target for model
getBuildDirGet build folder information from model build information
Simulink.fileGenControlSpecify root folders for files generated by diagram updates and model builds
RTW.reservedIdentifiersGet reserved identifiers for code generation (Since R2023b)


Generate Code

Code Generation with Project

Code Generation Files and Folders

Code Generation Tutorial