| Simulink Reference | ![]() |
Output a selection of contiguous bits from the input signal
Library
Description
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.
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
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
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.
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.
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.
Data Type Support
The Extract Bits block accepts inputs of any data type supported by Simulink, 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, refer to Data Types Supported by Simulink in the Using Simulink documentation.
Parameters and Dialog Box
Range starting with most significant bit or Range ending with least significant bit for the Bits to extract parameter.
[start end] format. The indices are assigned to the input bits starting with 0 at the least significant bit.
Range of bits for the Bits to extract parameter.
Preserve fixed-point scaling, the fixed-point scaling of the input is used to determine the output scaling during the data type conversion.
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.
Example
Consider an input signal that is represented in binary by 110111001:
Upper half for the Bits to extract parameter, the output is 11011 in binary.
Lower half for the Bits to extract parameter, the output is 11001 in binary.
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.
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.
Range of bits for the Bits to extract parameter, and specify [4 7] for the Bit indices parameter, the output is 1011 in binary.
Characteristics
| Direct Feedthrough |
Yes |
| Sample Time |
Inherited |
| Scalar Expansion |
N/A |
| States |
None |
| Dimensionalized |
Inherited |
| Zero Crossing |
No |
| Environment Controller | Fcn | ![]() |
© 1994-2005 The MathWorks, Inc.