Two Matlab Function Blocks generate the same random number
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Manan Mishra
le 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 commentaires
Voir également
Catégories
En savoir plus sur Sources dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!