フィルターのクリア

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

1 回表示 (過去 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 件のコメント
Walter Roberson
Walter Roberson 2020 年 7 月 2 日
for i=2:m
a(i,:)=bitxor(a(i-1, :),A(i,:));
end
lilly lord
lilly lord 2020 年 7 月 3 日
Thanks. You solved my problem

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by