circshift(a ',-n)'
You only need to enter the binary string A and the number of digits N that need to be shifted to the left to get the answer. For example:
& gt& gta = ' 100 1 1 1 10 '; n = 1; circshift(a ',-n)'
ans =
00 1 1 1 10 1
& gt& gta = ' 100 1 1 1 10 '; n = 2; circshift(a ',-n)'
ans =
0 1 1 1 10 10
& gt& gta = ' 100 1 1 1 10 '; n = 3; circshift(a ',-n)'
ans =
1 1 1 10 100
& gt& gta = ' 100 1 1 1 10 '; n = 4; circshift(a ',-n)'
ans =
1 1 10 100 1
The second parameter of the circshift function itself moves to the right if it is regular, and to the left if it is negative. And it can be used to shift matrices of any dimension, so I won't say much unless you ask questions.
If you use the internal binary form of your own value instead of the 0 1 string, there are two ways. One is to convert it into a binary string with dec2bin function, add 0 to the left to expand it to the number of digits you need, and then use the circshift function above.
Another method is to use the bitshift function, but it is a little more complicated to judge the length of the data type, whether it is signed or unsigned, and whether the highest bit is 1 or 0. Usually, it can simplify these problems by matching the fi function. See the documentation of bitshift and fi functions for details.