Matrix multiplication using XOR
이전 댓글 표시
I am multiplying two matrices together and instead of doing the regular addition I would to use XOR. I tried the XOR function but it gave me errors.
a = [2 3 1 1; 1 1 3 1; 1 1 2 3; 3 1 3 2]
b = [dec2hex(172);dec2hex(119);dec2hex(102);dec2hex(243)]
% prod = xor(a ,b)
prod = a * b
>> matrix
a =
2 3 1 1
1 1 3 1
1 1 2 3
3 1 3 2
b =
AC
77
66
F3
prod =
419 404
352 335
438 383
552 520
>>
댓글 수: 3
Walter Roberson
2016년 2월 27일
Your b is a character array. You are going to have problems multiplying character arrays or using xor on character arrays.
Are you wanting to do the xor at the level of the formal additions, like
a(1,1) * b(1) XOR a(2,1) * b(2) XOR a(3,1) * b(3) XOR a(4,1) * b(4)
or are you wanting to use xor even at the level of the multiplications, like 3 * b(1) meaning b(1) XOR b(1) XOR b(1) -- since, after all, multiplication is defined by repeated addition and you want your addition to be done as XOR?
"but it gave me errors": you do not show us any error message, and the code you have posted works just fine. So it seems that you don't have any problems after all. Congratulations!
Or perhaps you do have some problems, and just forgot to actually show us the complete error message and the exact code used and a description of what you expected to happen. If you want help you need to tell us what you are doing and what you expect your code to do.
Mandofa
2016년 2월 28일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!