circshift function working explanation needed
Show older comments
Completely new to matlab. Studying some sample codes.
% bitget and num2str and circular shift
x = 0b10011010u8 % x is 10011010
value3= bitget(x, 8:-1:1) % x's binary representation is 10011010
formatSpec4= '%d'
s4= num2str(value3, formatSpec4);
s5= s4;
s5(1:4) = circshift(s5(1:4),-1);
s6= s5;
Not able to understand the syntax and functionality of circshift. Thank in advance
Please explain me the functionality of circshift.
Accepted Answer
More Answers (1)
M = (10:10:40).' + (1:9)
circshift(M, -1)
You can see that this is the same as
[M(2:end,:); M(1,:)]
And more generally, circshift(M, -K) would be
[M(K+1:end,:); M(1:K,:)]
2 Comments
For vectors:
M = 1 : 9
circshift(M, -1)
which is [M(2:end),M(1)] .
When you specify a scalar for the shift, then circshift operates on the first non-singleton dimension.
Manu Chaudhary
on 16 Jan 2022
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!