Main Content

Simulate custom code in a separate process


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


Default: Off


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.

The following external debuggers are supported:

  • On Windows®, Microsoft® Visual Studio® debugger.

  • On Linux®, GNU® Data Display Debugger (DDD).

  • On macOS, LLDB Debugger (LLBD).


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.

Command-Line Information

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

Recommended Settings

DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

See Also

| | | |

Related Topics