フィルターのクリア

Invert bit vector ?

2 ビュー (過去 30 日間)
Henry Buck
Henry Buck 2016 年 3 月 5 日
編集済み: Henry Buck 2016 年 3 月 18 日
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

採用された回答

Stephen23
Stephen23 2016 年 3 月 5 日
>> 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 件のコメント
Walter Roberson
Walter Roberson 2016 年 3 月 6 日
Please format your entries.
Henry Buck
Henry Buck 2016 年 3 月 12 日
Hi, Thank you for Your answer.
I think I did not understand your last comment.
Henry

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by