フィルターのクリア

How can I Perform bitxor operation in matrix?

1 回表示 (過去 30 日間)
dani elias
dani elias 2022 年 8 月 22 日
編集済み: dani elias 2022 年 8 月 22 日
Assume You have two matrix A and B with even number of rows as shown below. I want the first column in A to undergo bitxor with the second column in B, and the second column in A with bitxor with first column in B. The same approach be applied with column 3 in A with column 4 in B as well as column 4 in A with third column in B.Assume you n even equal number of rows in both matrix. Is it possible to use for loop?
A=[1 2 3 4] and B=[11 22 33 44;3 4 5 6]
example bitxor(1,22),bitxor(1,4),bitxor(2,11),bitxor(3,44),bitxor(3,66),bitxor(4,33)
  2 件のコメント
Chunru
Chunru 2022 年 8 月 22 日
"A" has a single row.
dani elias
dani elias 2022 年 8 月 22 日
編集済み: dani elias 2022 年 8 月 22 日
Yes,A has only single row but B can have many rows and columns (the number of columns in both A and B are the same,(last column % 2=0))

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

採用された回答

Bruno Luong
Bruno Luong 2022 年 8 月 22 日
A=[1 2 3 4], B=[11 22 33 44;3 4 5 6],
A = 1×4
1 2 3 4
B = 2×4
11 22 33 44 3 4 5 6
C=zeros(max(size(A),size(B)))
C = 2×4
0 0 0 0 0 0 0 0
C(:,1:2:end)=bitxor(A(:,1:2:end),B(:,2:2:end));
C(:,2:2:end)=bitxor(A(:,2:2:end),B(:,1:2:end));
C
C = 2×4
23 9 47 37 5 1 5 1
  1 件のコメント
dani elias
dani elias 2022 年 8 月 22 日
編集済み: dani elias 2022 年 8 月 22 日
Thank you for the answer,this work better as i want.Thank you once again

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by