Jan 26, 2019 #1 C Chinmaye Full Member level 3 Joined Jan 18, 2016 Messages 164 Helped 0 Reputation 0 Reaction score 1 Trophy points 1,298 Activity points 3,145 Hello all, I am trying to add 2 binary numbers in matlab. Here is my code. Code: a = [0,0,0,1]; b = [0,0,0,0]; sum= str2double(num2cell(dec2bin(bin2dec(num2str(a))+bin2dec(num2str(b))))); Though i get the sum as 1, i would like to get it in the form sum= [0,0,0,1]; Please help.
Hello all, I am trying to add 2 binary numbers in matlab. Here is my code. Code: a = [0,0,0,1]; b = [0,0,0,0]; sum= str2double(num2cell(dec2bin(bin2dec(num2str(a))+bin2dec(num2str(b))))); Though i get the sum as 1, i would like to get it in the form sum= [0,0,0,1]; Please help.
Jan 26, 2019 #2 V vGoodtimes Advanced Member level 4 Joined Feb 16, 2015 Messages 1,089 Helped 307 Reputation 614 Reaction score 303 Trophy points 83 Activity points 8,730 you can use bi2de and de2bi. there is a 'left-msb' argument to avoid the need for fliplr.