Binary random generatior

Status
Not open for further replies.

chiu

Newbie level 3
Joined
Feb 19, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,316
how can i build a binary random generator in MATLAB and the output 0 and 1 with the same probability?

could you please write the code for me? cuz im a very newbie thank you

---------- Post added at 21:39 ---------- Previous post was at 20:35 ----------

i come up with a way to build it

i=1:100;
b=rand(1:length(i));
b(b>0.5)=1;
b(b<=0.5)=0;
plot(b)

do you think its good? OR do u have any other better way to build it? thanks
 

Probably you must to manage seed entry to avoid the function return same result always.

+++
 

Don't 0 and 1 have the same probability with a 50% duty-cycle square wave?

John
 

The Quantum Random Bit Generator Service has a free QRBG Matlab Toolbox available:

**broken link removed**

**broken link removed**
 
Reactions: blooz

    blooz

    Points: 2
    Helpful Answer Positive Rating
might help:

rand('seed',11111111)
N=100;
round(rand(N,1))
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…