Main Content

Logic and Bit Operations

R2026b
Blocks for Boolean logic, signal comparison, edge detection, and bit manipulation, such as Logical Operator and Relational Operator

Use blocks from the Logic and Bit Operations library to implement decision logic and signal monitoring in your model. You can perform Boolean operations, compare signals, detect rising and falling edges, and convert between bit fields and integers.

To add blocks from this library to your model, see Add Blocks to Models.

Blocks

Bit Clear blockBit ClearSet specified bit of stored integer to zero
Bit Set blockBit SetSet specified bit of stored integer to one
Bit to Integer Converter blockBit to Integer ConverterMap vector of bits to corresponding vector of integers
Bitwise Operator blockBitwise OperatorSpecified bitwise operation on inputs
Combinatorial Logic blockCombinatorial LogicImplement truth table
Compare To Constant blockCompare To ConstantDetermine how signal compares to specified constant
Compare To Zero blockCompare To ZeroDetermine how signal compares to zero
Detect Change blockDetect ChangeDetect change in signal value
Detect Decrease blockDetect DecreaseDetect decrease in signal value
Detect Fall Negative blockDetect Fall NegativeDetect falling edge when signal value decreases to strictly negative value, and its previous value was nonnegative
Detect Fall Nonpositive blockDetect Fall NonpositiveDetect falling edge when signal value decreases to nonpositive value, and its previous value was strictly positive
Detect Increase blockDetect IncreaseDetect increase in signal value
Detect Rise Nonnegative blockDetect Rise NonnegativeDetect rising edge when signal value increases to nonnegative value, and its previous value was strictly negative
Detect Rise Positive blockDetect Rise PositiveDetect rising edge when signal value increases to strictly positive value, and its previous value was nonpositive
Extract Bits blockExtract BitsOutput selection of contiguous bits from input signal
Extract Bits blockFloat Extract BitsExtract bits from floating-point input samples (Since R2023a)
Integer to Bit Converter blockInteger to Bit ConverterMap vector of integers to vector of bits
Interval Test blockInterval TestDetermine if signal is in specified interval
Interval Test Dynamic blockInterval Test DynamicDetermine if signal is in specified interval
Logical Operator blockLogical OperatorPerform specified logical operation on input
Relational Operator blockRelational OperatorPerform specified relational operation on inputs
Shift Arithmetic blockShift ArithmeticShift bits or binary point of signal

Tools

Library BrowserFind and add blocks to model

Topics