Xor(A, B), does A, B have to be the same dimension?
조회 수: 3 (최근 30일)
이전 댓글 표시
C = xor(A,B) performs a logical exclusive-OR of arrays A and B and returns an array containing elements set to either logical 1 (true) or logical 0 (false). So, A and B has to be the same dimension so it could compare, right? But in the example, A is a 1*2; while B is a 2*1 dimension matrix.
Can anyone help me explain it?
Thanks,
댓글 수: 2
채택된 답변
DGM
2022년 6월 12일
편집: DGM
2022년 6월 12일
The arguments don't necessarily need to have the same size/shape, but they need to have compatible size/shape. Like many things in modern versions, implicit array expansion applies here. I imagine the example in the docs is something like:
xor([0 1],[0;1]) % xor two vectors
which is equivalent to
xor([0 1; 0 1],[0 0; 1 1]) % the two vectors expanded to a common array size
Consider the similarity:
plus([1 2 3 4],[1;2]) % add two vectors
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!