Compare To Zero
Determine how signal compares to zero
Libraries:
      Simulink / 
      Logic and Bit Operations
   
      HDL Coder / 
      Logic and Bit Operations
   
Description
The Compare To Zero block compares an input signal to zero. Specify how the input is compared to zero with the Operator parameter.
The output is 0 if the comparison is false, and
                1 if it is true.
Examples
Bounded Variable-Size Signal Basic Operations
Generate bounded variable-size signals and illustrates some of the operations using those signals. In this example, you generate variable-size signals using the Selector block and the Switch block. The signals are used in math operations, bus creation, bus selection, matrix concatenation and to implement a discrete filter equation.
Ports
Input
Input signal, specified as scalar, vector, or matrix, is compared with
                            zero. If the input data type cannot represent zero, parameter overflow
                            occurs. To detect this overflow, go to the Diagnostics >
                                Data Validity pane of the Configuration Parameters dialog
                            box and set Parameters > Detect overflow to
                                warning or
                                error.
In this case, the block compares the input signal to the
                                ground value of the input data type. For
                            example, if you have an input signal of type
                                fixdt(0,8,2^0,10), the input data type can
                            represent unsigned 8-bit integers from 10 to 265 due to a bias of 10.
                            The ground value is 10, instead of 0.
Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point
Output
The output is 0 if the comparison is false, and
                                1 if it is true.
The block output is uint8 or
                                boolean, depending on your selection for the
                                Output data type parameter.
Data Types: uint8 | Boolean
Parameters
This parameter can have the following values:
- ==— Determine whether the input is equal to zero.
- ~ - =— Determine whether the input is not equal to zero.
- <— Determine whether the input is less than zero.
- <=— Determine whether the input is less than or equal to zero.
- >— Determine whether the input is greater than zero.
- >=— Determine whether the input is greater than or equal to zero.
Programmatic Use
| Block Parameter: relop | 
| Type: character vector | 
| Values: '=='|'~='|'<'|'<='|'>='|'>' | 
| Default: '<=' | 
Specify the data type of the output, boolean or
                            uint8.
Programmatic Use
| Block Parameter: OutDataTypeStr | 
| Type: character vector | 
| Values: 'boolean'|'uint8' | 
| Default: 'boolean' | 
Select to enable zero-crossing detection. For more information, see Zero-Crossing Detection.
Programmatic Use
| Block Parameter: ZeroCross | 
| Type: character vector | 
| Values: 'off'|'on' | 
| Default: 'on' | 
Block Characteristics
| Data Types | 
 | 
| Direct Feedthrough | 
 | 
| Multidimensional Signals | 
 | 
| Variable-Size Signals | 
 | 
| Zero-Crossing Detection | 
 | 
More About
If you have a Simulink® Coverage™ license, the Compare To Zero block receives condition coverage.
Condition coverage measures:
- The number of times that the comparison between the input and zero is true 
- The number of times that the comparison between the input and zero is false 
If you select the Relational boundary (Simulink Coverage) coverage metric, the Compare To Zero block receives relational boundary coverage. For more information, see Relational Boundary Coverage (Simulink Coverage).
Extended Capabilities
C/C++ Code Generation
 Generate C and C++ code using Simulink® Coder™.
HDL Coder™ provides additional configuration options that affect HDL implementation and synthesized logic.
This block has one default HDL architecture.
| ConstrainedOutputPipeline | Number of registers to place at
                        the outputs by moving existing delays within your design. Distributed
                        pipelining does not redistribute these registers. The default is
                                 | 
| InputPipeline | Number of input pipeline stages
                        to insert in the generated code. Distributed pipelining and constrained
                        output pipelining can move these registers. The default is
                                 | 
| OutputPipeline | Number of output pipeline stages
                        to insert in the generated code. Distributed pipelining and constrained
                        output pipelining can move these registers. The default is
                                 | 
This block supports code generation for complex signals.
PLC Code Generation
 Generate Structured Text code using Simulink® PLC Coder™.
Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™. 
Version History
Introduced before R2006a
See Also
Compare To Constant | Logical Operator | Bitwise Operator | String Compare
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)

