Register to reply 
I need help in partioning bits of random number in matlab 
Share this thread: 
#1
Apr1510, 08:38 PM

P: 21

Hey guys,
I really need your help here...What i wanted to do actually is to partition the bits into 4 smaller group.. If anyone of you can give me a basic coding of it or maybe u can check if there anything wrong wit my coding.. Ex: x=80 rand('state',100) randn('state',200) a=rand(1,x)>0.5 should i do for loop? should i add this function Ex: for x=(4:1:4) a=rand(1,x)>0.5 end but it will not give me a random number 0f 4 bits..how??? anyone can helpp please?? 


#2
Apr1510, 08:53 PM

Mentor
P: 21,283

and for the rand function  http://www.mathworks.com/access/help.../ref/rand.html If you need a loop it should look something like this.



#3
Apr1510, 09:04 PM

P: 21

Ok, let say i have 40 bits..
My question now is..how do i do 5 partition for the 40 bits (each partition consists of 8 bits)so that everytime i simulate it,it will randomly pick 8 bits from the 40 bits?? but i have to use this code in it: x=40 rand('state',100); randn('state',200); input=rand(1,x)>0.5 do you have any idea?? 


#4
Apr1610, 12:32 AM

Mentor
P: 21,283

I need help in partioning bits of random number in matlab
I don't think partitioning the set of bits enters into it. And your explanation is still not very clear. My best guess is that you have 40 bits to choose from, with indexes in the set {0, 1, 2, 3, 4, ..., 38, 39} and you want to pick 8 bits at random.
The following statement will store an integer from 0 through 39 in x. If you do that 8 times, you'll get 8 different values. x = fix(40 * rand) This code will put 8 values in an array.



#5
Apr1610, 01:03 AM

P: 21

and because of : rand('state',100); randn('state',200); a=rand(1,x)>0.5 .......this line will generate 0,1 with equal probility so my 40 bits just now are being generated as 0 and 1 and through that i want to partition it into 5 section( each of it will consist of 8 bits). The 8 bits will be choose randomly from the output I've given. Example of evaluate of that selection i have this output: x = 40 a = Columns 1 through 14 0 1 1 1 1 1 1 0 0 1 1 1 0 0 Columns 15 through 28 1 0 1 0 0 0 1 1 1 0 1 0 1 1 Columns 29 through 40 1 1 0 0 1 1 1 0 1 0 0 1 


Register to reply 
Related Discussions  
Sum of random number of random variables  Set Theory, Logic, Probability, Statistics  8  
Expectation and variance of a random number of random variables  Calculus & Beyond Homework  3  
Find the number of bits that can be stored on a 10cm disk  Advanced Physics Homework  1  
Partioning natural numbers  Linear & Abstract Algebra  2  
2 Bits of help neede for study Logarithm+Complex number  Precalculus Mathematics Homework  14 