"David Quilligan" <firstname.lastname@example.org> wrote in message <email@example.com>... > Hi, I have an array of unit8 binary numbers. I need to concatenate every 2nd row i.e. the first with the second, the third with fourth etc. and then each of these back to a decimal and have them all in one array. I having trouble finding a way to do this without creating many many new variables. Length of array will vary but will be in the 1000?s. So far I have: > > % Convert XAccel to binary (uint8) and flip MSB > XAccelBin = de2bi(XAccel, 'left-msb'); > > % Concatenate and change first row to a string > XAccelNewFirstRow = num2str([XAccelBin(2,:), XAccelBin(1,:)]); > > % Change first row back to decimal > XAccelNewFirstRow = bin2dec(XAccelNewFirstRow); > > % Concatenate and change second row to a string > XAccelNewSecondRow = num2str([XAccelBin(4,:), XAccelBin(3,:)]); > > % Change second row back to decimal > XAccelNewSecondRow = bin2dec(XAccelNewSecondRow); > > XAccelNewestFirstRow = [XAccelNewFirstRow; XAccelNewSecondRow]; > > Any help would be appreciated.
It's ok. Found a very simple and short solution. Just use: