Main Content

Import custom code

Description

Specify whether or not to parse available custom code variables and functions and compile custom code into its own simulation target. This option affects the C Caller block, the C Function block, the MATLAB Function block, the MATLAB System block, and Stateflow® charts.

Category: Simulation Target

Settings

Default: On

On

When this option is on, Simulink®:

  • Uses the same custom code for simulation with the C Caller block, the C Function block, the MATLAB Function block, the MATLAB System block, and Stateflow charts. When using the C Caller block or the C Function block, this option must be turned on.

  • Automatically rebuilds the custom code simulation target when specified custom code dependencies change.

  • Automatically rebuilds simulation targets for blocks using custom code when custom code changes.

  • Enables Just-In-Time (JIT) compilation of the C Caller block, the C Function block, the MATLAB Function block, the MATLAB System block, and Stateflow charts.

  • Allows the Enable custom code analysis option to enable Simulink Coverage™ and Simulink Design Verifier™ support for custom code.

  • Allows edit and compile time error detection for C interface errors from your model.

  • Calls specified initialize code and terminate code at the start and end of model simulation, respectively, regardless of whether any block in the model calls external custom code. See Initialize function and Terminate function.

  • Enables parsing of custom code to report unresolved symbols in Stateflow charts in your model.

  • Requires that your custom code be complete and not dependent on any other files in order to be built.

Off

When this option is off, Simulink:

  • Combines Simulation Target custom code dependencies with those specified by other means (coder.cinclude, coder.updateBuildInfo, and coder.ExternalDependency) in Stateflow charts that use MATLAB® as the action language, MATLAB Function blocks, and MATLAB System blocks.

  • Calls specified initialize code and terminate code only if necessary. If no block in the model calls external custom code, Simulink does not call the initialize code or the terminate code. See Initialize function and Terminate function.

Note

When this option is on, if you use the same custom code across different unique configurations, each unique configuration is treated as a separate unit even if the configurations refer to the same custom code. For instance, if you have a root-level model and a library subsystem that refer to the same custom code, then the custom code global variables accessed by the library block and the root-level model are different.

Note

In most cases, Import custom code should be selected. Clear the Import custom code parameter only if your custom code is incompatible with this parameter.

Command-Line Information

Parameter: SimParseCustomCode
Value: 'on' | 'off'
Default: 'on'

Recommended Settings

ApplicationSetting
DebuggingOn
TraceabilityNo impact
EfficiencyNo impact
Safety precautionOn

Related Topics