Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Incrementing Variables
Replies: 1   Last Post: Oct 12, 2013 5:02 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
David Quilligan

Posts: 10
Registered: 10/11/13
Incrementing Variables
Posted: Oct 11, 2013 6:51 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.