Chinmaye
Full Member level 3
Hello all,
I am trying to add 2 binary numbers in matlab. Here is my code.
Though i get the sum as 1, i would like to get it in the form
sum= [0,0,0,1];
Please help.
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.