pseduo decimal randeom number
Afficher commentaires plus anciens
can anyone have MATLAB code for pseduo decimal random number generator. pseduo decimal random number generator is initiated with some seed value which also has decimal number. It is iterative mathematical equcation.
5 commentaires
James Tursa
le 6 Mai 2021
Modifié(e) : James Tursa
le 6 Mai 2021
Don't know what you mean by pseudo decimal random number generator. What doesn't the rand( ) or randi( ) function do that you want? Can you give an example of the types of outputs you would expect?
Scott MacKenzie
le 6 Mai 2021
Modifié(e) : Scott MacKenzie
le 6 Mai 2021
Computer algorithms to generate random numbers are pseudo random. The seed you mention is built in to MATLAB's random number functions. So, again, it's not entirely clear what you are after.
If you want random decimal integers, use randi. For example, to generate 10 random integers in the range 1 to 5:
>> x = randi(5,1,10)
x =
1 5 2 2 3 3 5 5 3 5
John D'Errico
le 6 Mai 2021
Modifié(e) : John D'Errico
le 6 Mai 2021
Exactly what does rand do that does not satisfy you? Why do you think it is inadequate for your needs? You should consider that numbers in MATLAB, as double precision numbers are NOT decimal numbers anyway, since they are stored in binary form. The thing is, this is true for virtually all programming languages. So what would it gain you if you had some truly "decimal" random number generator?
sudhir keshari
le 7 Mai 2021
David Goodmanson
le 7 Mai 2021
Modifié(e) : David Goodmanson
le 7 Mai 2021
Hi sudir,
rng(12345)
rand(1,8)
rand(1,8)
disp('reset')
rng(12345)
rand(1,8)
rand(1,8)
ans = 0.9296 0.3164 0.1839 0.2046 0.5677 0.5955 0.9645 0.6532
ans = 0.7489 0.6536 0.7477 0.9613 0.0084 0.1064 0.2987 0.6564
reset
ans = 0.9296 0.3164 0.1839 0.2046 0.5677 0.5955 0.9645 0.6532
ans = 0.7489 0.6536 0.7477 0.9613 0.0084 0.1064 0.2987 0.6564
see help rng
From the Mathworks website: "A flag is a request to an editor to review and potentially close or delete content on MATLAB Answers". Flags are generally reserved for duplicate questions, totally off-topic questions, out-and-out spam etc. Since that does not apply here, it would be best if you deleted the flags.
Réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!