Compare Function
Purpose
Apply a compare expression to a continuous signal.
Library
Signals & Systems
Description
The Compare Function block generates a gate signal from a continuous signal by
means of relational operators. The input may be a scalar or vectorized continuous
signal, the output is always a scalar gate signal. The expression has C language
syntax and may consist of one or more of the components listed below. Arithmetic
and relational operators as well as mathematical functions may only be applied on
continuous signals. Logical operators may only be applied on the results of
comparisons.
- u -- the input of the block. If the input is vectorized, u(i) or u[i]
represents the ith element of the vector. To access the first element, enter
u(1), u[1], or u alone.
- Brackets
- Numeric constants
- Arithmetic operators (+ - * / ^)
- Relational operators (> < >= <=)
- Logical operators ( || !)
- Mathematical functions -- abs, acos, asin, atan, atan2, cos, cosh, exp,
log, log10, pow, sgn, sin, sinh, sqrt, tan, and tanh.
- MATLAB workspace variables
The Compare Function icon can be distinguished from the Gate Function by
the green instead of a brown input terminal.
Note This block is intended for
compound components that contain internally and/or externally controlled
switches. It is for expert use only. The block shall not be used to implement
controllers like a hysteresis type control, since this may lead to unexpected
simulation results. Controllers should always be implemented directly in
Simulink.
Parameters and Dialog Box
-
Expression
- The expression applied to the input signal, in C language syntax.
-
Input width
- The width of the input signal. The default is 2.