Main Content

Enable run-time recursion for MATLAB functions

Option to allow recursive functions in MATLAB Function blocks, Stateflow charts, and MATLAB System blocks

Model Configuration Pane: Simulation Target


The Enable run-time recursion for MATLAB functions parameter specifies whether to allow MATLAB® code for MATLAB Function blocks, Stateflow® charts, and MATLAB System blocks to contain recursive functions. Some coding standards, such as MISRA™, do not allow recursion. To increase the likelihood that generated code is compliant with MISRA C™, clear this parameter.


on (default) | off

Allows recursive functions and enables run-time recursion when generating code from MATLAB code that contains recursive functions.


Does not allow recursive functions. The software issues an error if you generate code from a model that uses MATLAB code that requires run-time recursion.

Recommended Settings

DebuggingNo recommendation
TraceabilityNo recommendation
EfficiencyNo recommendation
Safety precautionNo recommendation

Programmatic Use

Parameter: EnableRuntimeRecursion
Type: string | character vector
Values: 'on' | 'off'
Default: 'on'

Version History

Introduced in R2016b