Two Matlab Function Blocks generate the same random number
1 view (last 30 days)
Show older comments
In Simulink, I'm using a Matlab function block to generate Gaussian-distributed numbers at each time step. If I make a copy of that block and run it in parralel to the first one, it generates the same random number (instead of an independent one as actually wanted). A quick-and-dirty solution for this problem is to generate a random vector (in this example with a length of two) and let each block pick one element, but I'm wondering if there is a more elegant way to do it?
Thanks for your help!
0 Comments
Answers (1)
Manan Mishra
on 10 Jan 2018
You can use different seeds in your MATLAB function blocks to get different random numbers as output. Look at the following documentation for more information regarding this:
You can include something like this in your MATLAB functions before calling the random number generator function:
In block 1:
>> rng(1)
In block 2:
>> rng(2)
0 Comments
See Also
Categories
Find more on Sources in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!