This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Hit Crossing

Detect crossing point




The Hit Crossing block detects when the input reaches the Hit crossing offset parameter value in the direction specified by the Hit crossing direction property.

The block accepts one input of type double. If you select the Show output port check box, the block output indicates when the crossing occurs. If the input signal is exactly the value of the offset value after the hit crossing is detected, the block continues to output a value of 1. If the input signals at two adjacent points bracket the offset value (but neither value is exactly equal to the offset), the block outputs a value of 1 at the second time step. If the Show output port check box is not selected, the block ensures that the simulation finds the crossing point but does not generate output. If the input signal is constant and equal to the offset value, the block outputs 1 only if the Hit crossing direction property is set to either.

When the block's Hit crossing direction property is set to either, the block serves as an "Almost Equal" block, useful in working around limitations in finite mathematics and computer precision. Used for these reasons, this block might be more convenient than adding logic to your model to detect this condition.

When the block's Hit crossing direction property is set to either and the model uses a fixed-step solver, the block has the following behavior. If the output signal is 1, the block sets the output signal to 0 at the next time step, unless the input signal equals the offset value.

Data Type Support

The Hit Crossing block outputs a signal of type Boolean if Boolean logic signals are enabled (see Implement logic signals as Boolean data (vs. double)). Otherwise, the block outputs a signal of type double.


Hit crossing offset

The value whose crossing is to be detected.

Hit crossing direction

The direction from which the input signal approaches the hit crossing offset for a crossing to be detected.

Show output port

If selected, draw an output port.

Enable zero-crossing detection

Select to enable zero-crossing detection. For more information, see Zero-Crossing Detection.

Sample time


The sldemo_hardstop and sldemo_clutch models show how you can use the Hit Crossing block.

In the sldemo_hardstop model, the Hit Crossing block is in the Friction Model subsystem.

In the sldemo_clutch model, the Hit Crossing block is in the Friction Mode Logic/Lockup Detection subsystem.


Data Types


Sample Time

Inherited from driving block

Direct Feedthrough


Multidimensional Signals


Variable-Size Signals


Zero-Crossing Detection

Yes, if enabled

Code Generation


Introduced before R2006a

Was this topic helpful?