LabVIEW Communications System Design Suite

cancel
Showing results for 
Search instead for 
Did you mean: 

Set the random seed of the random number generator in Matlab Node

Solved!
Go to solution

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?

 

0 Kudos
Message 1 of 3
(4,744 Views)
Solution
Accepted by topic author steve0

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.

 

Message 2 of 3
(4,676 Views)

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

0 Kudos
Message 3 of 3
(4,671 Views)