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.

How to convert in Matlab a binary data [1 0 1 0] to an integer number [1010]?

Status
Not open for further replies.

mona_c

Junior Member level 1
Joined
Jan 1, 2006
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,476
hi

cany any one help in matlb formats...i want to reduce to gape b/w the bits in a no. e.g. 1 0 1 0 is the binary no. i want this no. as 1010..i.e. without the space b/w the bits..or vice versa.can i do so using matlab?

thanx in advance

Mona
 

matlab dec2binvec

hello mona_c;

as you know, in matlab the sequence of [1 0 1 0] and [1010] are different. in fact the former is a binary data with the length of 4 and the latter is an integer number and hence, if you want to convert a binary data such as [1 0 1 0] to an integer number such as [1010] you could use this procedure:

[1010]=1×10^4 + 0×10^3 + 1×10^2 + 0×10^0;

or in general sence:

a=[1 0 1 0] ;
b=0;
for i=1:length(a)
b=a(i)*10^(length(a)-i)+b;
end;
b

good luck.
 

dec2binvec matlab

try to use bin2binvec, i dont remember the exact code, but binary vector has the format that you want, if you are using decimal numbers and converting it to binary vector, use dec2binvec(decimal number), for more info, type 'help dec2binvec' on the matlab command line
 

bin to vector matlab

aboozar.hamidipoor said:
hello mona_c;

as you know, in matlab the sequence of [1 0 1 0] and [1010] are different. in fact the former is a binary data with the length of 4 and the latter is an integer number and hence, if you want to convert a binary data such as [1 0 1 0] to an integer number such as [1010] you could use this procedure:

[1010]=1×10^4 + 0×10^3 + 1×10^2 + 0×10^0;

or in general sence:

a=[1 0 1 0] ;
b=0;
for i=1:length(a)
b=a(i)*10^(length(a)-i)+b;
end;
b

good luck.

thanx for reply mr. aboozar

but u dint get my ques....i m not converting the no. from bin to dec....i wanna change the look of the same no. .i.e the same bin no. one with spaces...& one with no spaces b/w the bits of the no. hope i m clear now

Added after 4 minutes:

hermin said:
try to use bin2binvec, i dont remember the exact code, but binary vector has the format that you want, if you are using decimal numbers and converting it to binary vector, use dec2binvec(decimal number), for more info, type 'help dec2binvec' on the matlab command line

hello hermin

there is no such command as bin2bin even.....any other option? plzz
 

matlab binary vector

Dear mona_c

what you wanna do is actually not possible in matlab, you cannot change the display properties and make it works with two different settings on the same time.

sorry
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top