MATLAB: Adding Hexadecimal numbers helpmathematics Can someone help me how to add 2 hexadecimal numbers? I would appreciate the help and sentiment. I tried using: c=dec2hex(hex2dec(a)+hex2dec(b))); But it didn't work. Is there a correct way to do this? Best Answer Hi Jed Louise Lesma,Despite the extra bracket in your code (I removed it), the method you tried should work:a = '3afb';b = '2839';c=dec2hex(hex2dec(a)+hex2dec(b));Kind regards,Robert Related SolutionsMATLAB: Bit Flip-Bit Negation bitflip = @(val, n) bitxor(val, 2.^(n-1)); MATLAB: Input as the hexadecimal number Unfortunately, there is no support for hexadecimal literals. The best you can do is:a = hex2dec('3656174');b = hex2dec('454B5350');However, there is support for displaying in hexadecimal:format hexc = bitand(a, b) Related QuestionHow to add leading zeros to a number in Hex formatLoading 64-bit National Instruments library in 64-bit MatlabBitsrl of a hex value
Best Answer