bit flipping

조회 수: 20 (최근 30일)
mahaveer hanuman
mahaveer hanuman 2011년 4월 24일
[EDIT: Thu May 12 23:15:24 UTC 2011 Duplicate Removed - MKF]
a=[0 1 1 0 1 0 1 0 1 0 1 1 1 1 ................]=30 bits how to flip it by 6 bits
  댓글 수: 1
Paulo Silva
Paulo Silva 2011년 4월 24일
I'm not familiar with the bit flipping concept, can you give one example or provide more information?

댓글을 달려면 로그인하십시오.

채택된 답변

Paulo Silva
Paulo Silva 2011년 4월 24일
@Walter
I was waiting for mahaveer to show some effort :(
Just for the record here's my code:
c=[1 0 1 1 1 0 1 0 0 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1]
nbflip=6; %flip 6 bits
v=nbflip:nbflip:numel(c); %make a vector with all the index values of c to flip
c(v)=not(c(v)); %flip the bits

추가 답변 (2개)

Walter Roberson
Walter Roberson 2011년 4월 24일
a(6:6:end) = 1 - a(6:6:end);
  댓글 수: 1
mahaveer hanuman
mahaveer hanuman 2011년 4월 24일
thanks its working

댓글을 달려면 로그인하십시오.


mahaveer hanuman
mahaveer hanuman 2011년 4월 24일
eg:c=[1 0 1 1 1 0 1 0 0 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1] in every 6th element should change to 1 to 0 or 0 to 1
like 6th ,12th,18th ..... repsetive bit should change from 0 to 1 or 1 to 0 and rest of the bits should be same.
  댓글 수: 1
Paulo Silva
Paulo Silva 2011년 4월 24일
Ok now I understand but please don't accept your own answer because it ain't the solution for the problem.
I made the code but I wan't to be sure that you tried to solve the problem so I ask what have you done so far in order to solve the problem?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by