fixing of random number

2 vues (au cours des 30 derniers jours)
chan
chan le 23 Oct 2021
Commenté : chan le 23 Oct 2021
I know how to fixed a random number for Y .when i run the program multiple times i want the random value generated for Y is same for all time but i dnt want to fixed the "node " random number . How not to fixed the "node " random number? Could someone plz give me some suggestion
rng(1)
Y=randi(10);
node=randi(20);

Réponse acceptée

David Goodmanson
David Goodmanson le 23 Oct 2021
Modifié(e) : David Goodmanson le 23 Oct 2021
Hi Irani,
If I understand your question correctly,
rng(1)
Y = randi(10)
rng('shuffle')
node = randi(20)
gives the same value for Y but different values for node each time this script is run.
  1 commentaire
chan
chan le 23 Oct 2021
thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Random Number Generation dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by