08-16-2016 10:48 AM
Dear all,
I need to use some random variables inside a Matlab node in Labview Commsuite. I generate them with the function randn(). Is it possible to set the seed of the random number generator such that the random numbers are repeatable?
Solved! Go to Solution.
08-22-2016 09:21 PM
Hi Steve,
You can use randn('seed', seed) to initialize the random number generator. The seed should have a positive integer value. For example, randn('seed', 3). Also, this seed is global within the entire application. This means if the function randn() is called in multiple MathScript nodes which could run in parallel, the random results are not guaranteed to be the same after you modify any part of your code. But you should still get the same results for repeated runs of the same code.
08-23-2016 03:22 AM
Thank you very much, that was the solution!
By the way, interestingly enough randn() and rand() use different random seeds. So setting the seed for randn() does not control the seed of rand().
Cheers,
Steve