필터 지우기
필터 지우기

how do xor to cell array1*1?

조회 수: 1 (최근 30일)
reta jon
reta jon 2022년 3월 27일
댓글: reta jon 2022년 3월 27일
X=
1×1 cell array
{'10000000'}
Y=
1×1 cell array
{'01000000'}
Z=xor(X,Y)
Z={'11000000'}

채택된 답변

DGM
DGM 2022년 3월 27일
편집: DGM 2022년 3월 27일
Here's one way:
% binary as cellchar
X = {'10000000'};
Y = {'01000000'};
% convert to actual logical arrays
X = X{:}=='1';
Y = Y{:}=='1';
% do a thing
Z = xor(X,Y)
Z = 1×8 logical array
1 1 0 0 0 0 0 0
% convert back to cellchar i guess
map = '01';
Z = {map(Z+1)}
Z = 1×1 cell array
{'11000000'}
If you expect the answer you show, use
Z = ~xor(X,Y)
instead for XNOR
  댓글 수: 1
reta jon
reta jon 2022년 3월 27일
think you so much sir

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

추가 답변 (1개)

Image Analyst
Image Analyst 2022년 3월 27일
Try this:
X = {'10000000'};
Y = {'01000000'};
Z = bitxor(bin2dec(X{1}), bin2dec(Y{1})) % A decimal number.
Z = 192
% Convert to binary digits.
Z = dec2bin(Z) % Correct
Z = '11000000'
% Poster say the answer should be:
Z={'00111111'} % ? Huh?
Z = 1×1 cell array
{'00111111'}
I'm not sure you understand the concept of XOR. It's one, or the other, but not both. So where both bits match up the output is zero and where they are different it's one.
You can put Z into a cell if you want
Z = {dec2bin(Z)}
  댓글 수: 1
reta jon
reta jon 2022년 3월 27일
think you so much sir

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

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by