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.
Apps
Simulink Coder | Generate 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 |
Functions
Topics
Generate Code
- Generate Code by Using the Quick Start Tool
Prepare a model for quickly generating code for rapid prototyping. - Increase Code Generation Speed
Alter a model to increase the speed at which the code generator generates code. - 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. - Internationalization and Code Generation
Internationalization support for enabling efficient globalization. - What Is Code Replacement?
Why and how to replace code. Code replacement libraries that MathWorks provides. Contents of a code replacement library and how the code generator uses the contents. Terminology and limitations. - Replace Code Generated from Simulink Models
This example shows how to replace generated code by using a code replacement library. - Control Regeneration of Top Model Code
Choose options for regenerating code for the top-level model. - Set Up Model for Controlling Program Execution
Set up a model so that you can start and stop program execution for logging output, monitoring data, and tuning parameters. - Configure Model for Debugging
Configure a model so that generated code and the build process are set for debugging. - Reload Generated Code
Reload generated code from the Model Explorer. - Aircraft Position Radar Model
Generate code for model that contains an Extended Kalman Filter that estimates aircraft position from radar measurements.
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.
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. - Build Process Support for File and Folder Names
Troubleshoot build process errors that occur when file system issues prevent file processing.
Code Generation Tutorial
- Configure Model, Generate Code, and Simulate
Learn about model functional design, viewing top-level model and subsystems, and running simulations with this example.
- STEP 1: Configure Model and Generate Code
- STEP 2: Configure Data Interface
- STEP 3: Call External C Functions
- STEP 4: Check Model and Configuration for Code Generation