MATLAB: Xor operation on two numbers logical operation i have two numbers 23 and 47, i have to convert them into binary and then perform the Xor operation how to do that Best Answer Since decimal to binary conversion may not produce same length of inputs to xor, we need to append 0's before the binary valuein1 = 27;in2 = 47;x = dec2bin(in1);y = dec2bin(in2);if length(x)~=length(y) max_len = max(length(x), length(y)); x = [repmat('0', 1, max_len-length(x)), x]; y = [repmat('0', 1, max_len-length(y)), y];endresult = xor(x-'0', y-'0'); Related SolutionsMATLAB: Trouble with converting dec2bin x=[1 3 5 7];outx=dec2bin(x) MATLAB: How to convert a cell containig 8bit niary sequence to integer value A={'01001100' '01011110' '00110110' '10010100' '01100000' '01000000' '10011100' '00101101' '11011100'} B=cellfun(@bin2dec,A) Related QuestionBit setting a binary numberFrom logical to binaryConversion of binary to decimalConvert to binary
Best Answer