CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   how to generate random number? (https://www.cfd-online.com/Forums/main/11355-how-generate-random-number.html)

ztdep May 5, 2006 00:06

how to generate random number?
 
Hi;

i want to use a series a random number between 0 and 20, what should i do ? regards

ganesh May 5, 2006 02:38

Re: how to generate random number?
 
Dear ztdep,

You can look out for a lot of random number generators available on net. A simple option could be to use the 'rand()' command in MATLAB. For eg: rand(1) generates a random number between 0 and 1. Since you need the number between 0 and 20, all you need to do is use rand(1).*20, which would generate a random number in [0,20]. Note that all random number generators are pseudo-random, and there is nothing deterministic about multiplying the random number by 20. Hope this helps

Regards,

Ganesh

ztdep May 5, 2006 03:28

Re: how to generate random number?
 
Thank you very much! so what is the meaning of the pseudo-random? regards

ganesh May 5, 2006 05:31

Re: how to generate random number?
 
Dear ztdep,

Though we make use of a random number generator, it works on an underlying algorithm, which brings in an element of determinism. Therefore, these generators are referred to as pseudo-random, mening they are random generators, but do have an element of determinism owing to an underlying algorithm.

Regards,

Ganesh

vijesh joshi May 6, 2006 05:53

Re: how to generate random number?
 
Hello friends, I saw this message. I am with a question. Why do we need random numbers? What is its relation with CFD? Regards, VVJ.

ganesh May 6, 2006 07:52

Re: how to generate random number?
 
Dear Vijesh,

There are many applications for random number generators in various fields. In CFD, may be their use is not too much, however one which comes to my mind is for use in random perturbation of grid points, to study effect of grid distortions on accuracy, scheme stability etc ...

Regards,

Ganesh


ztdep May 8, 2006 06:20

Re: how to generate random number?
 
Hi:

i use it to generate a random heat source so as to validate my reduced order model !

regards


All times are GMT -4. The time now is 05:38.