Documentation

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 theCode GenerationandOptimizationpanes in the Configuration Parameters dialog box. The content of theCode Generationpane and its subpanes can change depending on the target that you specify. Some configuration options are available only with the Embedded Coder®product. TheOptimizationpane includes code generation parameters that help to improve the performance of the generated code.

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 theCode Generationpane. There are several different ways to open theCode Generationpane from the Simulink editor:

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

    Then clickCode Generationin theSelect(left) pane.

  • From theSimulationmenu, selectModel Configuration Parameters. When the Configuration Parameters dialog box opens, clickCode Generationin theSelect(left) pane.

  • From theCodemenu, selectC/C++ Code>Code Generation Options.

  • From theViewmenu in the model window, selectModel Explorer, or from the MATLAB®command line, typedaexplrand pressEnter. In the Model Explorer, expand the node for the current model in the left pane and clickConfiguration (active). Click elements in the middle pane to display the corresponding parameters in the right pane.

Note

In a 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 clickOK,Cancel, orApply, the background resets to white.

Configuration Tools

帮助你为代码generati配置您的模型on and to check your configuration against your code generation objectives,金宝app®Coder™and Embedded Coder®provide several tools.

Goal Approach More Information
Automate configuration. At the MATLAB command line, use theset_paramfunction Configure Code Generation Parameters for Model Programmatically
Configure your model for code generation quickly and easily (Embedded Coder). Embedded Coder Quick Start tool Generate Code with the Quick Start Tool(Embedded Coder)
Use a template to create a model configured for code generation, ready for you to add your own blocks. Code generation templates
配置您的米odel for code generation, use Simulink blocks and predefined or custom MATLAB scripts. Code Generation Wizards blocks Configure and Optimize Model with Configuration Wizard Blocks(Embedded Coder)
Verify that your model meets standards and guidelines. Model Advisor Select and Run Model Advisor Checks(Simulink)
Verify that your model meets your application objectives. Code Generation Advisor Application Objectives Using Code Generation Advisor

Related Topics

Was this topic helpful?