Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Binary addition matlab

Status
Not open for further replies.

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.
 

you can use bi2de and de2bi. there is a 'left-msb' argument to avoid the need for fliplr.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top