Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

how to generate a random digital sequence formed of only two bits

Asked by mary

mary (view profile)

on 12 Jan 2013

fo example how to generate 00 or 01 0r 10 or 11 randomly?

0 Comments

mary

mary (view profile)

Products

No products are associated with this question.

1 Answer

Answer by Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 12 Jan 2013
Accepted answer
   randi(2,2,1)'-1

4 Comments

José-Luis

José-Luis (view profile)

on 12 Jan 2013
 doc randi
Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 12 Jan 2013

randi(4,5,6) will generate a random matrix 5x6 with numbers from 1 to 4

In our case

randi(2,1,2) will generate array 1x2 with numbers from 1 to 2, to make it from 0 to 1

out=randi(2,1,2)-1
mary

mary (view profile)

on 12 Jan 2013

aha ok thanx indeed for your explination.

Azzi Abdelmalek

Azzi Abdelmalek (view profile)

Contact us