Thread Subject:
how to change rng randomization inside code

Subject: how to change rng randomization inside code

From: besbesmany besbesmany

Date: 27 Jun, 2012 15:19:09

Message: 1 of 3

for each run of code
i want to make fixed rondomization for part of code
(I use rng(0,'twister');) which is always fixed when i rerun the code

then i want to stop this fixation and generate radom values for the rest of code that differ for each run of code

what to do?

Subject: how to change rng randomization inside code

From: Alan_Weiss

Date: 27 Jun, 2012 17:41:03

Message: 2 of 3

On 6/27/2012 11:19 AM, besbesmany besbesmany wrote:
> for each run of code
> i want to make fixed rondomization for part of code
> (I use rng(0,'twister');) which is always fixed when i rerun the code
>
> then i want to stop this fixation and generate radom values for the
> rest of code that differ for each run of code
>
> what to do?
doc rng

You want ONE call to rng('shuffle') just before you start generating
your "random" values. Do not call rng('shuffle') inside a loop, or more
than once in any other way.

Alan Weiss
MATLAB mathematical toolbox documentation

Subject: how to change rng randomization inside code

From: besbesmany besbesmany

Date: 27 Jun, 2012 20:51:06

Message: 3 of 3

Thanks so so much
Alan_Weiss <aweiss@mathworks.com> wrote in message <jsfgjf$dr5$1@newscl01ah.mathworks.com>...
> On 6/27/2012 11:19 AM, besbesmany besbesmany wrote:
> > for each run of code
> > i want to make fixed rondomization for part of code
> > (I use rng(0,'twister');) which is always fixed when i rerun the code
> >
> > then i want to stop this fixation and generate radom values for the
> > rest of code that differ for each run of code
> >
> > what to do?
> doc rng
>
> You want ONE call to rng('shuffle') just before you start generating
> your "random" values. Do not call rng('shuffle') inside a loop, or more
> than once in any other way.
>
> Alan Weiss
> MATLAB mathematical toolbox documentation

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us