Clear Filters
Clear Filters

Invert bit vector ?

2 views (last 30 days)
Henry Buck
Henry Buck on 5 Mar 2016
Edited: Henry Buck on 18 Mar 2016
Hi,
I wonder how to make invert bit vector ?
*For example:*
I have A vector: A=[0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0] that mean 2 couples LSB are 1 0 1 0 and the rest are 01 0 1 0 1 0 1 0 1 0 1
And I want to invert it to B=[1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1] the result of the inverted vector should be MSB 1 0 1 0 and the rest couple bits 0 1 0 1 0 1 0 1 0 1 0 1.
Anyone knows how to do it ?
Thanks,
Henry

Accepted Answer

Stephen23
Stephen23 on 5 Mar 2016
>> A=[0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0];
>> B=[1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1];
>> C = [A(end-3:end),A(1:end-4)];
>> isequal(B,C)
ans =
1
  6 Comments
Walter Roberson
Walter Roberson on 6 Mar 2016
Please format your entries.
Henry Buck
Henry Buck on 12 Mar 2016
Hi, Thank you for Your answer.
I think I did not understand your last comment.
Henry

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!