Main Content

Specify Code Configuration Parameters Interactively

You can control many aspects of the code generation process interactively by using the Code Generation Settings dialog box. You can use this dialog box both from the command line and from the MATLAB® Coder™ app. When you generate code at the command line by using the codegen command with a configuration object, you can also modify the properties of the configuration object directly by using dot notation. See Specify Build Configuration Parameters at the Command Line Using Configuration Objects.

Open and Use the Code Generation Settings Dialog Box

You can access the Code Generation Settings dialog box from the command line or from the MATLAB Coder app. Certain app-specific parameters are only available if you open the dialog box from the app.

Using the MATLAB Coder App

To open the Code Generation Settings dialog box for your code generation project, click Settings > View all settings on the MATLAB Coder tab of the toolstrip. The parameters that you see in the Code Generation Settings Dialog box depend on whether you generate standalone code or a MEX function, as well as on the setting of the Use Embedded Coder features parameter.

At the Command Line

When you generate code at the command line, you must first create a code configuration object by using the coder.config function. The parameters that you see in the Code Generation Settings Dialog box depend on the type of code configuration object that you create. For example, create a coder.MexCodeConfig object named mexcfg:

mexcfg = coder.config("mex");

To open the Code Generation Settings dialog box for this config object, use one of these approaches:

  • In the MATLAB workspace, double-click the configuration object variable.

  • At the MATLAB command prompt, use the open command with the configuration object variable. For example:

    open mexcfg

  • Display the configuration object in the Command Window, and click the Edit Configuration Object link. For example:

    mexcfg
    mexcfg = 
    
        Description: 'class MexCodeConfig: MEX configuration objects with C code.'
        Name: 'MexCodeConfig'
    
    -------------------------------- Report -------------------------------
    ...
    ------------------------------ Code Style -----------------------------
    
                               CodeFormattingTool: 'Auto'
    
    Edit Configuration Object

Additional Functionalities in the Code Generation Settings Dialog Box

To enable you to easily modify code configuration parameters interactively, the Code Generation Settings dialog box provides these functionalities:

  • Search: When you search for a string, you see the filtered results across all the settings categories. The search string might be present in a setting name, the name of an option for a setting, or in a tooltip.

    Screen shot of sample search result in the configuration parameter dialog box.

  • Informative tooltips: The tooltip for each individual setting contains the corresponding configuration object property name, a Help link for that property, and the name of any additional product that using that property requires. If the property is disabled, the tooltip also contains links to other properties that you must set to enable this property. You can make that change in the tooltip itself.

    Screen shot of a tooltip.

  • Settings with nondefault values: The dialog box shows settings that have nondefault values in bold font. To reset such a setting to its default values, click the Reset button in the tooltip.

  • MISRA Compliance pane: If you generate standalone code with Embedded Coder® features enabled, the MISRA Compliance pane displays the settings that might impact MISRA™ compliance of the generated code. To set all of these settings to the recommended values, click Set to Recommended Values.

    See Generate C/C++ Code with Improved MISRA and AUTOSAR Compliance (Embedded Coder).

  • Generate equivalent script: You can view the command-line script that produces your current settings by clicking the Script button located at the bottom of the list of categories. You can switch from the script mode back to the interactive mode by clicking the Configure button.

    Script view of the configuration parameter dialog box.

See Also

| | | | | (Fixed-Point Designer)

Topics