Main Content

Enable zero-crossing detection for fixed-step simulation

Option to use zero-crossing detection with fixed-step solver

Since R2022a

Model Configuration Pane: Solver

Description

When you enable zero-crossing detection, you can sometimes use a larger step size without sacrificing accuracy. When a discontinuity occurs in the simulation, the zero-crossing algorithm calculates the time at which the discontinuity occurred and adjusts the continuous state values accordingly. By adjusting the state values only around discontinuities, the solver can retain the accuracy of a smaller step size with overall fewer calculations.

Consider enabling this parameter when your model contains continuous states.

The zero-crossing algorithm for fixed-step solvers has a bounded computational cost. You can adjust the maximum number of calculations that occur due to using zero-crossing detection by modifying the Maximum number of bracketing iterations and Maximum number of zero-crossings per step parameters.

Enabling this parameter enables these parameters:

Dependencies

To enable this parameter, set the solver Type to Fixed-step.

Settings

off (default) | on
off

Fixed-step solver does not detect or locate zero crossings during simulation.

on

Fixed-step solver detects and locates zero crossings during simulation.

Recommended Settings

The table summarizes recommended values for this parameter based on considerations related to code generation.

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

Programmatic Use

Parameter: EnableFixedStepZeroCrossing
Type: string | character vector
Value: 'on' | 'off'
Default: 'off'

Version History

Introduced in R2022a

expand all