How to convert binary bits of a vector, say m, after rotating it left by 1 bit, into decimal ?

1 view (last 30 days)
m = [16, 10]; % 1x2 array
a = fi(m, 0, 8, 0);
b = bin(bitrol(a, 1)); % Left rotate a by 1 bit
b = 00100000 00010100 % output , 1x19 char
c = bin2dec(b) % decimal representation of b
c = 8212 % output, not same as array 'm'
How to get back m ??
Please help!
  1 Comment
Abdul Gaffar
Abdul Gaffar on 11 Jan 2021
A small improvement:
m = [16, 10]; % 1x2 array
a = fi(m', 0, 8, 0); % m is changed to m' , where ' denotes transpose
b = bin(bitrol(a, 1)); % Left rotate a by 1 bit
% b = 00100000 00010100 % output , 1x19 char
c = bin2dec(b) % decimal representation of b
d = c' % Added
% d = [32, 20] % output in array format
Thanks!

Sign in to comment.

Accepted Answer

David Hill
David Hill on 11 Jan 2021
m = [16; 10]; %use column vector
a = fi(m, 0, 8, 0);
b = bin(bitrol(a, 1));
c = bin2dec(b);
  3 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Argument Definitions 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!