Main Content

Zero-crossing control

Option to control how zero-crossing detection is enabled in the model

Model Configuration Pane: Solver

Description

With zero-crossing detection enabled, each time a discontinuity, or zero-crossing, is detected in simulation, the solver determines the time at which the zero crossing occurred and uses this information to adjust the values of continuous states in the model.

For most models, enabling zero-crossing detection speeds up simulation by allowing the solver to take larger time steps while maintaining computational accuracy.

  • When you enable zero-crossing detection for a variable-step solver, the ability to compensate state values based on the location of the discontinuity prevents the solver from taking many small time steps near that time.

  • When you enable zero-crossing detection for a fixed-step solver, you can use a larger fixed time step without sacrificing accuracy in models that have continuous states.

Dependencies

This parameter is always enabled when you set the solver Type to Variable-step.

To enable this parameter when you set the solver Type to Fixed-step, select Enable zero-crossing detection for fixed-step simulation.

When you use a variable-step solver, setting Zero-crossing control to either Use local settings or Enable all enables these parameters:

Settings

Use local settings (default) | Enable all | Disable all
Use local settings

When you select this option, you enable or disable zero-crossing detection for each block in your model that registers zero crossings using the block parameters.

Each block reference page indicates whether that block supports zero-crossing detection. To enable or disable the parameter that specifies whether zero-crossing detection is enabled for a block, double-click the block to open the Block Parameters dialog box or select the block and press Ctrl+Shift+I to open the Property Inspector. On macOS, press command+option+O instead.

Enable all

This option enables zero-crossing detection for all blocks in the model that register zero crossings regardless of the parameter setting on each block.

Disable all

This option disables zero-crossing detection for all blocks in the model that register zero crossings regardless of the parameter setting on each block.

Tips

For models that have large dynamic changes, disabling zero-crossing detection can speed up the simulation but can also decrease the accuracy of simulation results. For more information, see Zero-Crossing Detection.

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: ZeroCrossControl
Type: string | character vector
Value: 'UseLocalSettings' | 'EnableAll' | 'DisableAll'
Default: 'UseLocalSettings'

Version History

Introduced before R2006a