Main Content

Command-Line API to Set Simulation and Code Generation Parameters

In Stateflow® charts in Simulink® models, you can use the command-line API to set options in the Model Configuration Parameters dialog box for simulation and embeddable code generation, .

Set Parameters at the Command Line

  1. At the MATLAB® command prompt, type:

    object_name = getActiveConfigSet(gcs)

    This command returns an object handle to the model settings in the Model Configuration Parameters dialog box for the current model.

  2. To set a parameter for that dialog box, type:

    object_name.set_param('parameter_name', value)

    This command sets a configuration parameter to the value that you specify.

For example, you can set the Reserved names parameter for simulation by typing:

cp = getActiveConfigSet(gcs)
cp.set_param('SimReservedNameArray', {'abc','xyz'})

Note

You can also get the current value of a configuration parameter by typing:

object_name.get_param('parameter_name')

For more information about using get_param and set_param, see the Simulink documentation.

Simulation Parameters for Nonlibrary Models

The following table summarizes the parameters and values that you can set for simulation of nonlibrary models using the command-line API.

Parameter and ValuesDialog Box EquivalentDescription

SimIntegrity

'off', 'on'

Ensure memory integrityDetect violations of memory integrity in code generated for MATLAB Function blocks and stop execution with a diagnostic.

SFSimEcho

'off', 'on'

Echo expressions without semicolonsEnable run-time output to appear in the MATLAB Command Window during simulation.

SimCtrlC

'off', 'on'

Ensure responsivenessEnable responsiveness checks in code generated for MATLAB Function blocks.

SimBuildMode

'sf_incremental_build', 'sf_nonincremental_build', 'sf_make', 'sf_make_clean', 'sf_make_clean_objects'

Simulation target build modeSpecify how you build the simulation target for a model.

SimReservedNameArray

string array{}

Symbols > Reserved namesEnter the names of variables or functions in the generated code that match the names of variables or functions specified in custom code to avoid naming conflicts.

SimParseCustomCode

'off', 'on'

Import custom codeSpecify whether or not to parse the custom code and report unresolved symbols for the C charts in a model.

SimCustomSourceCode

string''

Source fileEnter code lines to appear near the top of a generated source code file.

SimCustomHeaderCode

string''

Header fileEnter code lines to appear near the top of a generated header file.

SimCustomInitializer

string''

Initialize functionEnter code statements that execute once at the start of simulation.

SimCustomTerminator

string''

Terminate functionEnter code statements that execute at the end of simulation.

SimUserIncludeDirs

string''

Include directories

Enter a space-separated list of folder paths that contain files you include in the compiled target.

Note

If your list includes any Windows® paths that contain spaces, each instance must be enclosed in double quotes within the argument, for example,

'C:\Project "C:\Custom Files"'

SimUserSources

string''

Source filesEnter a space-separated list of source files to compile and link into the target.

SimUserLibraries

string''

LibrariesEnter a space-separated list of static libraries that contain custom object code to link into the target.

Simulation Parameters for Library Models

The following table summarizes the simulation parameters that apply to library models.

Parameter and ValuesDialog Box EquivalentDescription

SimUseLocalCustomCode

'off', 'on'

Use local custom code settings (do not inherit from main model)Specify whether a library model can use custom code settings that are unique from the main model to which the library is linked.

SimCustomSourceCode

string''

Source fileEnter code lines to appear near the top of a generated source code file.

SimCustomHeaderCode

string''

Header fileEnter code lines to appear near the top of a generated header file.

SimCustomInitializer

string''

Initialize functionEnter code statements that execute once at the start of simulation.

SimCustomTerminator

string''

Terminate functionEnter code statements that execute at the end of simulation.

SimUserIncludeDirs

string''

Include directories

Enter a space-separated list of folder paths that contain files you include in the compiled target.

Note

If your list includes any Windows paths that contain spaces, each instance must be enclosed in double quotes within the argument, for example,

'C:\Project "C:\Custom Files"'

SimUserSources

string''

Source filesEnter a space-separated list of source files to compile and link into the target.

SimUserLibraries

string''

LibrariesEnter a space-separated list of static libraries that contain custom object code to link into the target.

Related Topics