Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

How to separate binary values ?

Asked by I Made

I Made (view profile)

on 12 Mar 2013

I try to convert String to Binary , and after that i want to get

A [0 1 0 1 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 1 0 0];

   word = 'TEST';
   binary = dec2bin(word);

And we got 01010100 01000101 01010011 01010100, how i can separate all the binary value into 1 by 1 , it's only consist 0 and 1?

0 Comments

I Made

I Made (view profile)

Products

No products are associated with this question.

2 Answers

Answer by the cyclist

the cyclist (view profile)

on 12 Mar 2013
Accepted answer
word = 'TEST';
binary = dec2bin(word)';
binary(:)-'0'

Does this do what you want? (Notice I needed to take a transpose.)

1 Comment

I Made

I Made (view profile)

on 12 Mar 2013

Yeah right, thank you

the cyclist

the cyclist (view profile)

Answer by Shashank Prasanna

Shashank Prasanna (view profile)

on 12 Mar 2013

No direct way, but some jugglery:

A = (reshape(binary',1,7*4))-'0'

0 Comments

Shashank Prasanna

Shashank Prasanna (view profile)

Contact us