Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Incrementing Variables
Posted:
Oct 11, 2013 6:51 PM


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, 'leftmsb'); % 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.



