Two Matlab Function Blocks generate the same random number
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Manan Mishra
2018 年 1 月 10 日
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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!