Reading values from array and changing them to one big binary array

Hello I'm currently trying to make the values of an array of size (1 X 4000000) into binary with left-msb, the values only range from 1-4. I have used de2bi (d,'left-msb') but this is doing and not doing what I need at the same time. What I need is a giant 1 X 1 matrix were the 1 column stores all the binary values from the array I'm reading it off of, in sequence so if the first 4 values of my big array are 1,2,3,4..then I would want my new array to look something like [001010011100...] thank you.

 Akzeptierte Antwort

a=randi([1 4],1,4000000);
aBinary=dec2bin(a);
aBinary=reshape(aBinary,1,size(aBinary,1)*size(aBinary,2));%returns char

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by