how do xor to cell array1*1?
    1 回表示 (過去 30 日間)
  
       古いコメントを表示
    
採用された回答
  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)
% convert back to cellchar i guess
map = '01';
Z = {map(Z+1)}
If you expect the answer you show, use 
Z = ~xor(X,Y)
instead for XNOR
その他の回答 (1 件)
  Image Analyst
      
      
 2022 年 3 月 27 日
        Try this:
X = {'10000000'};
Y = {'01000000'};
Z = bitxor(bin2dec(X{1}), bin2dec(Y{1})) % A decimal number.
% Convert to binary digits.
Z = dec2bin(Z) % Correct
% Poster say the answer should be:
Z={'00111111'} % ? Huh?
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)}
参考
カテゴリ
				Help Center および File Exchange で Logical についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


