Decimal to Binary Conversion

1 Ansicht (letzte 30 Tage)
Zeeshan Abbas
Zeeshan Abbas am 20 Jun. 2019
Beantwortet: James Tursa am 20 Jun. 2019
As,
d = (1:5);
b = de2bi(d,4,'left-msb'); will give us...
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
But, I need the output to be like this:
b = 00010010001101000101 i.e. in the form of bit-stream.
How can I achieve this?

Akzeptierte Antwort

James Tursa
James Tursa am 20 Jun. 2019
E.g.,
bstream = reshape(b',1,[]);
If you want characters, then
bstream = char(reshape(b',1,[]) + '0');

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by