convert an array of 0s and 1s to binary & reverse
Ältere Kommentare anzeigen
hi Community,
I have an array of type double that contain only zeros and ones.
i want to convert it to binary value like below
[0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1] ----> [0 255]
and do the same thing in reverse
already tried de2bi()
but nothing !!!
2 Kommentare
Rik
am 13 Jun. 2021
@Stephen, isn't that the normal encoding? 0-255 is a normal 8 bit range, right? Or am I confused?
Akzeptierte Antwort
Weitere Antworten (1)
B = [0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1];
D = pow2(7:-1:0)*reshape(B,8,[])
Kategorien
Mehr zu Numeric Types finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!