| Simulink® | ![]() |
Logic and Bit Operations

The Extract Bits block allows you to output a contiguous selection of bits from the stored integer value of the input signal. The Bits to extract parameter defines the method by which you select the output bits.
Select Upper half to output the half of the input bits that contain the most significant bit. If there is an odd number of bits in the input signal, the number of output bits is given by the equation
![]()
Select Lower half to output the half of the input bits that contain the least significant bit. If there is an odd number of bits in the input signal, the number of output bits is given by the equation
![]()
Select Range starting with most significant bit to output a certain number of the most significant bits of the input signal. Specify the number of most significant bits to output in the Number of bits parameter.
Select Range ending with least significant bit to output a certain number of the least significant bits of the input signal. Specify the number of least significant bits to output in the Number of bits parameter.
Select Range of bits to indicate a series of contiguous bits of the input to output in the Bit indices parameter. You indicate the range in [start end] format, and the indices of the input bits are labeled contiguously starting at 0 for the least significant bit.
The Extract Bits block accepts inputs of any data type supported by Simulink® software, including fixed-point data types. Floating-point inputs are passed through the block unchanged. Boolean inputs are treated as uint8 signals.
For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink® in the Simulink documentation.

Select the mode by which to extract bits from the input signal, as discussed in Description.
(Not shown on dialog above.) Select the number of bits to output from the input signal.
This parameter is only visible if you select Range starting with most significant bit or Range ending with least significant bit for the Bits to extract parameter.
(Not shown on dialog above.) Specify a contiguous range of bits of the input signal to output. Specify the range in [start end] format. The indices are assigned to the input bits starting with 0 at the least significant bit.
This parameter is only visible if you select Range of bits for the Bits to extract parameter.
Select the scaling mode to use on the output bits selection:
When you select Preserve fixed-point scaling, the fixed-point scaling of the input is used to determine the output scaling during the data type conversion.
When you select Treat bit field as an integer, the fixed-point scaling of the input is ignored, and only the stored integer is used to compute the output data type.
Consider an input signal that is represented in binary by 110111001:
If you select Upper half for the Bits to extract parameter, the output is 11011 in binary.
If you select Lower half for the Bits to extract parameter, the output is 11001 in binary.
If you select Range starting with most significant bit for the Bits to extract parameter, and specify 3 for the Number of bits parameter, the output is 110 in binary.
If you select Range ending with least significant bit for the Bits to extract parameter, and specify 8 for the Number of bits parameter, the output is 10111001 in binary.
If you select Range of bits for the Bits to extract parameter, and specify [4 7] for the Bit indices parameter, the output is 1011 in binary.
Direct Feedthrough | Yes |
Sample Time | Inherited |
Scalar Expansion | N/A |
States | None |
Dimensionalized | Inherited |
Zero Crossing | No |
![]() | Environment Controller | Fcn | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |