MATLAB: How isolate binary hi, I converted decimal no. (10) into binary using x=dec2bin(10,15)=000000000001010 i want to isolate each 5 bits alone, then convert it again into decimal . I don't know how isolate each 5 bits alone. thanks Best Answer v = 10;x = dec2bin(v, 15); % '000000000001010'y = transpose(reshape(x, 5, 3)); % ['00000'; '00000'; '01010']bin2dec(y) % [0, 0, 10]Or without the slow step over the binary string:floor(rem(v ./ [1, 32, 32*32], 32)) Related SolutionsMATLAB: Converting 4 bits to 5 bits usea1 = dec2bin(mod(2^5+a,2^5),5) MATLAB: How to convert demodulated binary bits into image s=num2cell(reshape(x,8,[])',2)b=cellfun(@(x) bin2dec(strrep(num2str(x),' ','')),s);out=reshape(b,n,m); % your original image is nxm Related QuestionCovert 128 binary string into hex decimalTrouble with converting dec2binHow to split binary and convert to decimalHow to convert a string to binary and then from the binary back to stringHow to convert a negative integer to a binary string, in other words, how can I find Two’s Complement in MATLAB
Best Answer