Operators in MATLAB - Bitwise Operators
Different types of operators are used in MATLAB. We will be discussing the Bitwise operators here. It is assumed that the reader of this article has some basic knowledge of MATLAB. For a detailed discussion of arithmetic operators click on the following link.
bitand, bitor, bitxor, bitcmp, and bitshift.
Important Note: In all of the following examples the matrices A and B are supposed to be unsigned integers declared using data type uint8 unless otherwise specified.
This command returns the bitwise-and of the two arguments A and B. For example if A=[1 0; 1 1] and B=[0 1; 1 1] then bitand(uint8(A), uint8(B)) will result in [0 0;1 1]
This command returns the bitwise-or of the two arguments A and B. For example if A=[1 0; 1 1] and B=[0 1; 1 1] then bitor(uint8(A), uint8(B)) will result in [1 1;1 1]
This command returns the bitwise-exclusive or of the two arguments A and B. For example if A=[1 0; 1 1] and B=[0 1; 1 1] then bitxor(uint8(A), uint8(B)) will result in [1 1;0 0]
This command returns the bitwise-complement of the argument A. For example if A=[1 0; 1 1] then bitcmp(uint8(A)) will result in [254 255;254 254]
Following is taken from MATLAB help.
C = BITSHIFT(A,K) returns the value of A shifted by K bits. A must be an unsigned integer. Shifting by K is the same as multiplication by 2^K. Negative values of K are allowed and this corresponds to shifting to the right, or dividing by 2^ABS(K) and truncating to an integer. If the shift causes C to overflow the number of bits in theunsigned integer class of A, then the overflowing bits are dropped.
More by this Author
This article presents a comparison between the time-frequency analysis and the Wavelet analysis. The Short-time Fourier transform is used for the purpose of time-frequency analysis. We have presented examples to...
Samples of Argument tasks given in GRE and other similar tests like TWe, GMAT etc.
Learn how to write an effective curriculum vitae, or resume, and look at several examples.
No comments yet.