Main Content

Code Generation Basics

Overview of code generation process

The basic steps for code generation are:

  • Open a model

  • Configure the model for code generation by selecting the solver, target, the language, and the code generation objectives

  • Select the build approach (for example, toolchain approach)

  • Build the model

The model configuration parameters provide many options for the code generation and build process.


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


Getting Started

Generate Code Using Simulink® Coder™

Select a system target file for a Simulink® model, generate C code for real-time simulation, and view generated files.

Configure Model, Generate Code, and Simulate

Learn about model functional design, viewing top-level model and subsystems, and running simulations with this example.

Generate Code by Using the Quick Start Tool

Prepare a model for quickly generating code for rapid prototyping.

Aircraft Position Radar Model

Generate code for model that contains an Extended Kalman Filter that estimates aircraft position from radar measurements.

Code Generation Files and Folders

Manage Build Process Folders

Manage folders that the code generator creates.

Manage Build Process Files

Work with generated source files and dependency files that the code generator produces.

Manage Build Process File Dependencies

Work with generated source files and dependency files that the code generator produces.

Add Build Process Dependencies

Add dependency information for external code to the build process.

Build Process Support for Folder Names

Troubleshoot build process errors that occur when file system issues prevent file processing.

Options for More Code Generation Control

Internationalization and Code Generation

Internationalization support for enabling efficient globalization.

Code Generation with Project

Generate Code and Simulate Models in a Project

This example shows how to use the code generation template for a new Project.

Generate Code and Simulate Models Programmatically with Project

This example shows how to use the Project API to create a new project and automate project tasks for manipulating files.