MATLAB Answers

0

Decimal to Binary Conversion

Asked by Zeeshan Abbas on 20 Jun 2019
Latest activity Answered by James Tursa
on 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?

  0 Comments

Sign in to comment.

1 Answer

Answer by James Tursa
on 20 Jun 2019
 Accepted Answer

E.g.,
bstream = reshape(b',1,[]);
If you want characters, then
bstream = char(reshape(b',1,[]) + '0');

  0 Comments

Sign in to comment.