How to fix a randomly generated sample in Matlab after making some changes to the code?
    5 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
I need to have the same sample (same data points) that was generated from a large set of data in order to make some comparisons as I vary some conditions or parameters. However, the sample changes after each Matlab run. My current sampling is based on the use of "randperm" or sampling without replacement.
Any help would e greatly appreciated. Thanks.
0 commentaires
Réponse acceptée
  Stephen23
      
      
 le 7 Août 2015
        
      Modifié(e) : Stephen23
      
      
 le 7 Août 2015
  
      s = rng;
x = rand(1,5)
x =
    0.8147    0.9058    0.1270    0.9134    0.6324
rng(s);
y = rand(1,5)
y =
    0.8147    0.9058    0.1270    0.9134    0.6324
You can also use the seed option to reset the random numbers to a known starting point:
rng(N)
More information on this topic:
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
			
	Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

