how can i generate real random numbers?

7 vues (au cours des 30 derniers jours)
Ameer Kadhim
Ameer Kadhim le 13 Mar 2018
Modifié(e) : John D'Errico le 13 Mar 2018
hello everyone... i want to generate three real random number between 0 and 1 and must be the total of them equal to 1 if i use this code
a = rand(1); b = 1-a;
what c is ? please help me ...

Réponse acceptée

James Tursa
James Tursa le 13 Mar 2018
Modifié(e) : James Tursa le 13 Mar 2018
  1 commentaire
Ameer Kadhim
Ameer Kadhim le 13 Mar 2018
thank you so much...

Connectez-vous pour commenter.

Plus de réponses (1)

John D'Errico
John D'Errico le 13 Mar 2018
Modifié(e) : John D'Errico le 13 Mar 2018
First, they are not truly random if you use a computer and an algorithm. They will only be pseudo-random. So they will at best have characteristics that will be consistent with random numbers. But if you want to generate "real" random numbers, then there are ways to do so, sometimes based on things like radioactive decay.
Next, you cannot generate random numbers as you tried. Instead, you want to use a tool like randfixedsum. Find it on the file exchange, James gave you the link already.

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