Setting up a counter in a RNG (Random Number Generator)

2 ビュー (過去 30 日間)
Om
Om 2016 年 3 月 10 日
編集済み: Stephen23 2016 年 3 月 10 日
Hi all
I am running an experiment with MatLab and for robustness I am using RNG (1),(2),(3),(4),(5), etc manually editing each time.
I am looking for a way to set up a counter that will automatically increase by 1 each time the loop is finished, all the way up to 10.
As a bonus I am going to attempt to set up a name string that will label which RNG was used.
Can someone help with the counter?
I tried this but it doesnt work
ctr=1
rng(ctr)
ctr=ctr+1

回答 (1 件)

Stephen23
Stephen23 2016 年 3 月 10 日
編集済み: Stephen23 2016 年 3 月 10 日
Why not just put it in a for-loop:
for k = 1:10
rng(k)
str = sprintf('rng %f',k)
... your code
end

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by