필터 지우기
필터 지우기

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