フィルターのクリア

parfor and rng(1)

6 ビュー (過去 30 日間)
mingcheng nie
mingcheng nie 2022 年 8 月 19 日
コメント済み: mingcheng nie 2022 年 8 月 24 日
Hi there,
I was doing matlab simulation based on different SNR and rng, and want to use parfor to speed up, can we do like this?(can we use rng together with parfor?)
rng(1)
count=10000;
for SNR=20:5:50
for i = 1: count
chan_coef = randn(1,1)+1i*randn(1,1);
...
end
end
%Is It Correct to Change to
rng(1)
count=10000;
parfor SNR=20:5:50
parfor i = 1: count
chan_coef = randn(1,1)+1i*randn(1,1);
...
end
end
Thanks,
Charlie
  1 件のコメント
mingcheng nie
mingcheng nie 2022 年 8 月 24 日
thank you for your comments!

サインインしてコメントする。

採用された回答

Bruno Luong
Bruno Luong 2022 年 8 月 19 日
編集済み: Bruno Luong 2022 年 8 月 19 日
rdn(1) outside the parfor has no effect.
from the doc:
"For independent streams on the workers, use the default behavior or consider using a unique substream on each worker using RandStream."
So you should leave the parfor loop alone or use RandSteam inside parfor loop (but not rdn('shuffle') as warned the doc).

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Parallel Server についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by