Main Content

Time tolerance

Definition of consecutive zero crossings

Model Configuration Pane: Solver


The software defines zero crossings as consecutive if the time between events is smaller than an interval defined by the time tolerance. Consider a simulation in which the software detects zero crossings ZC1 and ZC2, bracketed at successive time steps t1 and t2.

A timeline drawn as an axis that points from left to right, annotated on the left with zero crossing ZC1 at time t1 and on the right with ZC2 at time t2. The interval between t1 and t2 is labeled dt.

The software considers the zero crossings consecutive when the interval dt between t1 and t2 is less than the product of the specified time tolerance timetol and the larger time t2.

dt < timetol * t2

The software counts the number of consecutive zero crossings detected and issues a diagnostic when the count exceeds the amount specified by the Number of consecutive zero crossings parameter. You can specify whether the diagnostic is a warning or an error using the Consecutive zero-crossings violation parameter. The counter resets when the simulation progresses without detecting another zero crossing long enough for the next zero crossing to be considered nonconsecutive.


To enable this parameter, set the solver Type to Variable-step and set Zero-crossing control to either Use local settings or Enable all.


10*128*eps | positive scalar number

Decreasing the time tolerance specifies a stricter definition for consecutive. A lower time tolerance can provide more flexibility for a model to recover from behaviors and conditions that result in many discontinuities.


For models that experience excessive zero crossings, consider increasing the value for the Number of consecutive zero crossings parameter to relax the condition for when the software issues a diagnostic about the number of detected zero crossings.

Recommended Settings

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

DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

Programmatic Use

Parameter: ConsecutiveZCsStepRelTol
Type: string | character vector
Value: positive scalar number
Default: '10*128*eps'

Version History

Introduced before R2006a