필터 지우기
필터 지우기

Bit xor of row with the next row and the output is again xored with the next row

조회 수: 2 (최근 30일)
Hi, I have a image and I want to xor first row with single number then Xor 2nd row with first, the output is xored aith the next row and so on. I hope some one can figure out the mistake
for example
c=245;
A=[23 2 13;34 56 70;12 18 90];
a=[];
[m n]=size(A);
for i=2:m
a1=bitxor(c,A(1,:)); %Xor c with each element of first row of A
(a(i),:)=bitxor(a(i-1),A(i,:));% error ,Index exceeds matrix dimension
end

채택된 답변

Walter Roberson
Walter Roberson 2020년 7월 1일
c = 245;
A = [23 2 13;34 56 70;12 18 90];
a = [];
[m, n] = size(A);
a(1,:) = bitxor(c,A(1,:)); %Xor c with each element of first row of A
for i = 2:m
a(i,:) = bitxor(a(i-1),A(i,:));
end
  댓글 수: 3

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by