Main Content

Code Generation Configuration

When you are ready to generate code for a model, you can modify the model configuration parameters specific to code generation. The code generation parameters determine how the code generator produces code and builds an executable program from your model.

The model configuration parameters for code generation are in the Code Generation and pane in the Configuration Parameters dialog box. The content of the Code Generation pane and its subpanes can change depending on the target that you specify. Some configuration options are available only with the Embedded Coder® product.

Your application objectives can include a combination of these code generation objectives: debugging, traceability, execution efficiency, and safety precaution. There are tradeoffs associated with these configuration choices, such as execution speed and memory usage. To help configure a model to achieve your application objectives, use the Model Advisor and the Code Generation Advisor.

Open the Model Configuration for Code Generation

To modify the model configuration parameters for code generation, open the Code Generation pane. There are several different ways to open the Code Generation pane from the Simulink editor:

  • To open the Configuration Parameters dialog box, click the model configuration parameters icon.

    Then, click Code Generation in the left pane.

  • On the C Code tab, select Settings > Code Generation Settings.

  • On the Modeling tab, click Model Explorer, or from the MATLAB® command line, type daexplr and press Enter. In the left pane of the Model Explorer, expand the node for the current model and click the Configurations node. In the Contents pane, right-click the configuration and select Open from the context menu. Then click Code Generation in the left pane.


In the Configuration Parameters dialog box, when you change the value of a check box, menu selection, or edit field, the white background of the element changes color to indicate that you made an unsaved change. When you click OK, Cancel, or Apply, the background resets to white.

Configuration Tools

To help you configure your model for code generation and to check your configuration against your code generation objectives, Simulink® Coder™ and Embedded Coder provide several tools.

GoalApproachMore Information
Automate configuration.At the MATLAB command line, use the set_param functionConfigure Code Generation Parameters for Model Programmatically
Configure your model for code generation quickly and easily.Quick Start tool
Use a template to create a model configured for code generation, ready for you to add your own blocks.Code generation templates

Generate Code and Simulate Models in a Project

To configure your model for code generation, use Simulink blocks and predefined or custom MATLAB scripts.Code Generation Wizards blocksConfigure and Optimize Model with Configuration Wizard Blocks (Embedded Coder)
Verify that your model meets standards and guidelines.Model AdvisorCheck Your Model Using the Model Advisor
Verify that your model meets your application objectives.Code Generation AdvisorApplication Objectives Using Code Generation Advisor

Related Topics