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

Thread Subject:
pseudorandom number generation

Subject: pseudorandom number generation

From: Arman

Date: 19 Jan, 2012 17:04:10

Message: 1 of 4

Dear all,

I need 3 digits( 1, 2 and 3) each one generated for 10 times (a total of 30) in a random order. How could I do this in MATLAB?

Any input is appreciated.

All the best,
Arman

Subject: pseudorandom number generation

From: John D'Errico

Date: 19 Jan, 2012 17:09:11

Message: 2 of 4

"Arman " <arman.eshaghi@gmail.com> wrote in message <jf9iea$nuq$1@newscl01ah.mathworks.com>...
> Dear all,
>
> I need 3 digits( 1, 2 and 3) each one generated for 10 times (a total of 30) in a random order. How could I do this in MATLAB?
>
> Any input is appreciated.
>

What does this do for you?

[~,idx] = sort(rand(10,3),2);

John

Subject: pseudorandom number generation

From: Roger Stafford

Date: 19 Jan, 2012 17:14:10

Message: 3 of 4

"Arman " <arman.eshaghi@gmail.com> wrote in message <jf9iea$nuq$1@newscl01ah.mathworks.com>...
> I need 3 digits( 1, 2 and 3) each one generated for 10 times (a total of 30) in a random order. How could I do this in MATLAB?
- - - - - - - -
 v = repmat(1:3,1,10);
 v = v(randperm(10*3));

Roger Stafford

Subject: pseudorandom number generation

From: Arman

Date: 19 Jan, 2012 17:20:10

Message: 4 of 4

Excellent!

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <jf9inm$os6$1@newscl01ah.mathworks.com>...
> "Arman " <arman.eshaghi@gmail.com> wrote in message <jf9iea$nuq$1@newscl01ah.mathworks.com>...
> > Dear all,
> >
> > I need 3 digits( 1, 2 and 3) each one generated for 10 times (a total of 30) in a random order. How could I do this in MATLAB?
> >
> > Any input is appreciated.
> >
>
> What does this do for you?
>
> [~,idx] = sort(rand(10,3),2);
>
> John

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us