MATLAB: Mapping two binary bits to one bits I have generate a set of bits 0 and 1, N=10000; m=(sign(randn(1,N))+1)/2; The problem is how do I group the bits? For example 00=-j 01=-1 10=1 11=j Best Answer vals = [-1j, -1, 1, 1j];m2 = reshape(m, 2, []);idx = m2(1,:) * 2 + m(2,:) + 1;output = vals(idx); Related SolutionsMATLAB: How to convert a 64 bit, two’s complement value(binary vector)[ 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] into a signed integer swapbytes(typecast(uint8(bin2dec(char(reshape(fliplr(A),8,[]).' + '0'))),'int64')) MATLAB: Binary to decimal – 8 bits at a time You can try something like this using bin2dec :for i=1:8:numel(binary) decimal=bin2dec(num2str(binary(i:i+7))) % todo : save value of decimalend Related QuestionCan anyone help me to run this code , thank you
Best Answer