how to do bitxor operation of two 1*255 matrix

답변 (2개)

Greg
Greg 2018년 11월 30일
편집: Greg 2018년 11월 30일

0 개 추천

result = h1 | h3;
Edit: this is logical (bit) or, not xor. As posted elsewhere, simply use the xor function.

댓글 수: 4

moni sinha
moni sinha 2018년 11월 30일
Error using |
Matrix dimensions must agree.
how to correct it?
and while doing bitxor operation the dimension is changed.
Screenshot (36).png
Guillaume
Guillaume 2018년 11월 30일
Your screenshot clearly shows that h1 is 1x254, and c is 1x256. So yes, you're going to get an error telling you that their size do not match.
Note that |is the or operator, not the xor operator.
Jan
Jan 2018년 11월 30일
The error message is clear: The array sizes are different. Here the variables h1 (logical) and c (double) are concerned. So why do you ask for "h1 =1x255 logical, h3 = 1x255 logical"?
Greg
Greg 2018년 11월 30일
편집: Greg 2018년 11월 30일
Good catch Guillaume, i kept reading or not xor.
Why are we assuming c is the second argument? The original post explicitly states h1 and h3, both are logical and same size. All following posts are new problems to the original question.

댓글을 달려면 로그인하십시오.

James Tursa
James Tursa 2018년 11월 30일
편집: James Tursa 2018년 11월 30일

0 개 추천

It's not entirely clear to me what operation you really want, but if the elements of h1 and h2 represent "bits", then you could just do this:
result = (h1 ~= h2); % equivalent of xor between the elements of h1 and h2
If h1 and h2 don't have the same number of elements, then that is a different problem that you will need to fix before doing the xor operation.

댓글 수: 2

Or
result = xor(h1, h2);
Greg
Greg 2018년 11월 30일
Guillaume's comment here should be a separate answer, and accepted.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

질문:

2018년 11월 30일

편집:

2018년 11월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by