Different results by or(A,B) and xor(A,B) for matrices, why?
이전 댓글 표시
Hi, with or(A,B) and xor(A,B) I obtain two different results here, I don't understand why this happens. Since or(A,B) perform a logical OR of A and B, and xor(A,B) does the same exclusively, why are the results different?
Thanks
A=[1 2; 5 6; 8 9]
B=[1 2; 4 5; 6 7]
or(A,B)
ans = 3×2 logical array
1 1
1 1
1 1
xor(A,B)
ans = 3×2 logical array
0 0
0 0
0 0
채택된 답변
추가 답변 (1개)
Rishi
2024년 1월 23일
0 개 추천
Hi Sergio,
I understand that you want to know why are you getting the provided output.
When you apply the 'xor' function to two matrices, the output is 1 if and only if any one of the element at that position holds a non-zero value. You can refer the below documentation for further information:
Whereas in the case of 'or' function, the output is 1 when at least one of the element at that position holds a non-zero value.You can refer the below documentation for further information:
Hope this helps!
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!