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.

to count number of bits in matlab

Status
Not open for further replies.

chitra ranganath

Member level 2
Joined
May 15, 2011
Messages
50
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,568
hi
i want to know how to calculate the total number of bits.

00000100 1 0 01000100 0 00111110 0 01000100 0 00000100 0 00000010

here i have the delimiter as space and more over i`ve stored this in a register z. pls help me out. i need matlab code
 

thank u sir one more doubt will same command give output for bytes in form
z=
0000100
1000001
1000000
0000100
1000001
1000000
0000100
1000001
1000000
 

z_ini = '00000100 1 0 01000100 0 00111110 0 01000100 0 00000100 0 00000010 ';

z = strread(regexprep(z_ini,' ',''),'%8s',-1)

-----------------

Perhaps could have been:

z_ini = '00000100 1 0 01000100 0 00111110 0 01000100 0 00000100 0 00000010 '; % initial string

z_1 = regexprep(z_ini,' ','') ; % remove spaces
nbits = length(z_1) ; % bit count
z = strread(z_1,'%8s',-1) ; % Ascii byte array

Note:
It's a string array,
 

no sir the command which u gave is working properly and i obtained proper result also. but my doubt is if bits are like one below the other
z=
10010101
10101010
11110001
like this how to count the number of bits? bcos the command which u gave wil work only for string. so shd i convert these aray like appearance of bits to string as
z= 10010101, 10101010 ,11110001 and then count?????
 

I don't understand what you want to do, if that is the format, just write nbits = 8*length(z)
 

z=
10010101
10101010
11110001
i jus want to count number of bits in this.
 

Well, but wich is the format of z?
- String array of variable length?
- Integer array of fixed length ?
- Integer array of variable length starting with 1 ?
- Etc, etc ....
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top