Explanation

Controlling random number generation using rand or randn is no longer recommended. Use these functions only to generate random numbers and the new rng function to control the generation process.


Suggested Action

Update your code using the following table that shows replacements for discouraged syntaxes with an integer seed sd or a time-dependent seed.

Before

 

After

rand('twister',sd)

 

rng('default')

rand('seed',sd)

 

rng(sd)

randn('seed',sd)

 

rng(sd)

rand('state',sd)

 

rng(sd)

randn('state',sd)

 

rng(sd)

rand('seed',sum(100*clock))

 

rng('shuffle')

For more information including how to reproduce discouraged behavior with the rng function, see Replace Discouraged Syntaxes of rand and randn.