채택된 답변

Roger Stafford
Roger Stafford 2014년 10월 18일

3 개 추천

If I understand what you want and if the rows have a multiple of three elements, this should work for you:
X = xor(xor(M(:,1:3:end-2),M(:,2:3:end-1)),M(:,3:3:end));
If this is not what you want, you should clarify that phrase "every three bits together" so that it is clearly understood. As it stands, it is easily misunderstood. It should be simple to make it clear what you mean if you carefully construct a good, meaningful example.

댓글 수: 4

jim
jim 2014년 10월 18일
편집: jim 2014년 10월 18일
thanks roger.. it works , but for 32 bit file it doesn't work right until i add zero to the last left bit. so i need this code to add zero automatically if the number of bits is not a multiple of three elements,how to make the code do this automatically ?
How about this:
[m,n] = size(M);
M2 = [M,zeros(m,3*ceil(n/3)-n)];
X = xor(xor(M2(:,1:3:end-2),M2(:,2:3:end-1)),M2(:,3:3:end));
When you used the word 'last' I thought you wanted the extra zeros appended to the right end. Apparently you want them appended to the left end. If that is the case, just reverse the order:
[m,n] = size(M);
M2 = [zeros(m,3*ceil(n/3)-n),M];
X = xor(xor(M2(:,1:3:end-2),M2(:,2:3:end-1)),M2(:,3:3:end));
jim
jim 2014년 10월 19일
thank you very much,, it works fine

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

태그

질문:

jim
2014년 10월 18일

편집:

jim
2014년 10월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by