# Check Static Gap

Check that gap exists in signal's range of amplitudes

Libraries:
HDL Coder / Model Verification

## Description

The Check Static Gap block checks that an input signal is less than (or optionally equal to) a static lower bound or greater than (or optionally equal to) a static upper bound at the current time step. The Upper bound and Lower bound parameters define the upper and lower bounds of the gap. The block then executes an assertion after comparison. If the signal falls outside of the gap, the assertion is `true (1)` and the block does nothing. If not, the block halts the simulation and returns an error message by default.

The input signal and bounds can be scalars, vectors, or matrices. The input and the bounds must be the same data type. The block compares the value of the input to the bounds differently depending on the signal.

• When comparing scalars to vectors or matrices, the block compares the scalar to each element of the non-scalar input signal or bound.

• When comparing vectors or matrix signals to other vectors or matrices, the block compares the input signal and the bounds element-by-element.

• For models with more than one vector or matrix as the input signal or bounds, the vectors or matrices must have the same dimensions.

## Examples

expand all

Using the Check Static Gap block, you can check if an input signal enters an unchanging gap of values.

In this example, the Check Static Gap block compares the value of a Sine Wave block to the values entered in the Upper bound and Lower bound parameters, which are `0.5` and `0`. The Constant blocks, labeled Upper Bound and Lower Bound, illustrate these parameters in the Scope block but do not affect the parameter values. The Check Static Gap block checks if the value of the input signal is less than the Lower bound value or greater than the Upper bound value. If it is, the block asserts `true (1)`. Because the Output assertion signal parameter of the block is selected, the block outputs the assertion value. Run the simulation to observe the model output.

At the start of the simulation, the Check Static Gap block outputs `0` because the value of the Sine Wave block is less than the Upper bound value. At a time of `0.52`, the sine wave exceeds `0.5`. The Check Static Gap block recognizes this change and outputs `1`. When the time reaches `2.62`, the sine wave falls below the Upper bound value and the assertion is `false`. When the time reaches `3.14`, the sine wave falls below the Lower bound value. The Check Static Gap block recognizes this change and outputs `1`. The output stays at `1` until the time is `6.28`, when the sine wave then exceeds the Lower bound value. This pattern repeats until the simulation end time.

## Ports

### Input

expand all

Input signal the block checks if the signal value is less than a static lower bound or greater than a static upper bound.

Data Types: `half` | `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `Boolean` | `fixed point` | `enumerated` | `bus`

### Output

expand all

Output signal that is `true (1)` if the assertion succeeds, and `false (0)` if the assertion fails. If, in the Configuration Parameters window, in the Math and Data Types section, under Advanced parameters, you select Implement logic signals as Boolean data, then the output data type is `Boolean`. Otherwise, the data type of the signal is `double`.

#### Dependencies

To enable this output port, set the Output assertion signal parameter check box.

Data Types: `double` | `Boolean`

## Parameters

expand all

Specify the upper bound on the range of amplitudes that the input signal can have.

#### Programmatic Use

 Parameter: `max` Type: string scalar or character vector Default: `"0"`

Select this check box to make the range of valid input amplitudes include the upper bound.

#### Programmatic Use

 Parameter: `max_included` Type: string scalar or character vector Values: `"on"` | `"off"` Default: `"on"`

Specify the lower bound on the range of amplitudes that the input signal can have.

#### Programmatic Use

 Parameter: `min` Type: string scalar or character vector Default: `"0"`

Select this check box to make the range of valid input amplitudes include the lower bound.

#### Programmatic Use

 Parameter: `min_included` Type: string scalar or character vector Values: `"on"` | `"off"` Default: `"on"`

Clearing this parameter disables the block and causes the model to behave as if the block does not exist. To enable or disable all verification blocks, regardless of the setting of this option, go to the Configuration Parameters window, click Diagnostics > Data Validity, expand the Advanced parameters section, and set Model Verification block enabling to ```Enable all``` or `Disable all`.

#### Programmatic Use

 Parameter: `enabled` Type: string scalar or character vector Values: `"on"` | `"off"` Default: `"on"`

Specify a MATLAB® expression to evaluate when the assertion fails. Because the expression is evaluated in the MATLAB workspace, define all variables used in the expression in that workspace.

#### Dependencies

To enable this parameter, select the Enable assertion parameter.

#### Programmatic Use

 Parameter: `callback` Type: string scalar or character vector Default: `""`

Select this parameter to stop the simulation when the check fails. Clear this parameter to display a warning and continue the simulation.

#### Programmatic Use

 Parameter: `stopWhenAssertionFail` Type: string scalar or character vector Values: `"on"` | `"off"` Default: `"on"`

Select this parameter to enable the output port.

#### Programmatic Use

 Parameter: `export` Type: string scalar or character vector Values: `"on"` | `"off"` Default: `"off"`

Specify the style of the block icon. The `graphic` option displays a graphical representation of the assertion condition on the icon. The `text` option displays a mathematical expression that represents the assertion condition.

#### Programmatic Use

 Parameter: `icon` Type: string scalar or character vector Values: `"graphic"` | `"text"` Default: `"graphic"`

## Block Characteristics

 Data Types `Boolean` | `double` | `enumerated` | `fixed point` | `half` | `integer` | `single` Direct Feedthrough `no` Multidimensional Signals `yes` Variable-Size Signals `no` Zero-Crossing Detection `no`

## Version History

Introduced before R2006a