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.

 采纳的回答

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

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

产品

标签

Community Treasure Hunt

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

Start Hunting!

Translated by