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