Skip to Main Content Skip to Search
Product Documentation

Using Command-Line API to Set Simulation and Code Generation Parameters

How to Set Parameters at the Command Line

To programmatically set options in the Configuration Parameters dialog box for simulation and embeddable code generation, you can use the command-line API.

  1. At the MATLAB command prompt, type:

    object_name = getActiveConfigSet(gcs)

    This command returns an object handle to the model settings in the 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'})

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 in the Configuration Parameters dialog box that you can set for simulation of nonlibrary models using the command-line API. The parameters are listed in the order that they appear in the Configuration Parameters dialog box.

Parameter and ValuesConfiguration Parameters Dialog Box EquivalentDescription

SFSimEnableDebug

string – 'off', 'on'

Simulation Target > Enable debugging / animationEnable debugging and animation of a model during simulation and also enables the Stateflow Debugger.

SFSimOverflowDetection

string – 'off', 'on'

Simulation Target > Enable overflow detection (with debugging)Enable overflow detection of data during simulation. Overflow occurs for data when a value assigned to it exceeds the numeric capacity of the data type.

    Note   To enable this option, you must also select the Data Range check box in the Stateflow Debugger window.

SimIntegrity

string – 'off', 'on'

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

SFSimEcho

string – 'off', 'on'

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

SimBlas

string – 'off', 'on'

Simulation Target > Use BLAS library for faster simulationEnable MATLAB Function blocks in Simulink models and MATLAB functions in Stateflow charts to speed up low-level matrix operations during simulation.

SimCtrlC

string – 'off', 'on'

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

SimBuildMode

string – 'sf_incremental_build', 'sf_nonincremental_build', 'sf_make', 'sf_make_clean', 'sf_make_clean_objects'

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

SimReservedNameArray

string array{}

Simulation Target > 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

string – 'off', 'on'

Simulation Target > Custom Code > Parse custom code symbolsSpecify whether or not to parse the custom code and report unresolved symbols in a model.

SimCustomSourceCode

string''

Simulation Target > Custom Code > Source fileEnter code lines to appear near the top of a generated source code file.

SimCustomHeaderCode

string''

Simulation Target > Custom Code > Header fileEnter code lines to appear near the top of a generated header file.

SimCustomInitializer

string''

Simulation Target > Custom Code > Initialize functionEnter code statements that execute once at the start of simulation.

SimCustomTerminator

string''

Simulation Target > Custom Code > Terminate functionEnter code statements that execute at the end of simulation.

SimUserIncludeDirs

string''

Simulation Target > Custom Code > Include directoriesEnter a space-separated list of folder paths that contain files you include in the compiled target.

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

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

SimUserSources

string''

Simulation Target > Custom Code > Source filesEnter a space-separated list of source files to compile and link into the target.

SimUserLibraries

string''

Simulation Target > Custom Code > 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. The parameters are listed in the order that they appear in the Configuration Parameters dialog box.

Parameter and ValuesConfiguration Parameters Dialog Box EquivalentDescription

SimUseLocalCustomCode

string – 'off', 'on'

Simulation Target > 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''

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

SimCustomHeaderCode

string''

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

SimCustomInitializer

string''

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

SimCustomTerminator

string''

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

SimUserIncludeDirs

string''

Simulation Target > Include directoriesEnter a space-separated list of folder paths that contain files you include in the compiled target.

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

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

SimUserSources

string''

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

SimUserLibraries

string''

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

Code Generation Parameters for Nonlibrary Models

The following table is a partial list of the parameters and values in the Configuration Parameters dialog box that you can set for embeddable code generation using the command-line API. The parameters are listed in the order that they appear in the Configuration Parameters dialog box.

Parameter and ValuesConfiguration Parameters Dialog Box EquivalentDescription

UseSimReservedNames

string – 'off', 'on'

Code Generation > Symbols > Use the same reserved names as Simulation TargetSpecify whether to use the same reserved names as those specified for simulation. (Applies only if the model contains MATLAB Function blocks, Stateflow charts, or Truth Table blocks.)

ReservedNameArray

string array{}

Code Generation > 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.

RTWUseSimCustomCode

string – 'off', 'on'

Code Generation > Custom Code > Use the same custom code settings as Simulation TargetSpecify whether to use the same custom code settings as those specified for simulation. (Applies only if the model contains MATLAB Function blocks, Stateflow charts, or Truth Table blocks.)

CustomSourceCode

string''

Code Generation > Custom Code > Source fileEnter code lines to appear near the top of a generated source code file.

CustomHeaderCode

string''

Code Generation > Custom Code > Header fileEnter code lines to appear near the top of a generated header file.

CustomInitializer

string''

Code Generation > Custom Code > Initialize functionEnter code statements that execute once at the start of simulation.

CustomTerminator

string''

Code Generation > Custom Code > Terminate functionEnter code statements that execute at the end of simulation.

CustomInclude

string''

Code Generation > Custom Code > Include directoriesEnter a space-separated list of folder paths that contain files you include in the compiled target.

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

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

CustomSource

string''

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

CustomLibrary

string''

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

Code Generation Parameters for Library Models

The following table summarizes the code generation parameters that apply to library models. The parameters are listed in the order that they appear in the Configuration Parameters dialog box.

Parameter and ValuesConfiguration Parameters Dialog Box EquivalentDescription

RTWUseSimCustomCode

string – 'off', 'on'

Code Generation > Use the same custom code settings as Simulation TargetSpecify whether to use the same custom code settings as those specified for simulation. (Applies only if the model contains MATLAB Function blocks, Stateflow charts, or Truth Table blocks.)

RTWUseLocalCustomCode

string – 'off', 'on'

Code Generation > 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.

CustomSourceCode

string''

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

CustomHeaderCode

string''

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

CustomInitializer

string''

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

CustomTerminator

string''

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

CustomInclude

string''

Code Generation > Include directoriesEnter a space-separated list of folder paths that contain files you include in the compiled target.

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

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

CustomSource

string''

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

CustomLibrary

string''

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

For more information about parameters and values you can specify for embeddable code generation, see Parameter Command-Line Information Summary in the Simulink Coder documentation.

  


Free Stateflow Interactive Kit

Learn how engineers use Stateflow to model state machines in their Simulink models.


Get free kit

Trials Available

Try the latest version of Stateflow.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS