주요 콘텐츠

Simulate custom code in a separate process

Option to run custom code in a separate process outside of MATLAB during simulation

Model Configuration Pane: Simulation Target

Description

The Simulate custom code in a separate process parameter specifies whether to run custom code in a separate process outside of MATLAB® during model simulation. This option applies to external code integrated into the model using C Caller, C Function, MATLAB Function, and MATLAB System blocks and Stateflow® charts.

Category: Simulation Target

Settings

off | on
on

Custom code runs in a separate process during model simulation, thus preventing a MATLAB crash due to unexpected exceptions in the custom code or errors in the interface between Simulink® and the custom code. A run-time exception in the custom code produces an error message in Simulink that provides detailed information about the exception, such as which block or line number is responsible, to help resolve any issues with the code. If a supported external debugger is installed, the error message provides a button to launch the external debugger. For more information, see Debug Custom C/C++ Code.

Selecting this parameter allows you to map a pointer type argument of a custom code C function to an output port of a C Caller block without explicitly specifying its size in the Port Specification table of the block. See Map C Function Arguments to Simulink Ports.

off

Custom code runs in the same process as the rest of the model during simulation. Simulation usually runs faster, but a run-time exception in the custom code could cause MATLAB to crash.

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

Programmatic Use

Parameter: SimDebugExecutionForCustomCode
Value: "on" | "off"
Default: "off"

Version History

Introduced in R2021a