for loop in parfor
17 ビュー (過去 30 日間)
古いコメントを表示
I want to use a for-loop inside parfor, is it possible? If not what is the alternative?
Thanks,
0 件のコメント
採用された回答
Edric Ellis
2011 年 6 月 17 日
Yes, it's possible. For example,
parfor ii=1:10
for jj=1:10
x(ii,jj) = rand
end
end
Note that this example is so computationally trivial that it is much slower than a serial version.
6 件のコメント
Edric Ellis
2012 年 7 月 2 日
@Benoit - which version are you running? The ability to recognise 'x' as a sliced variable was added relatively recently.
@Walter - matlabpool workers (either local workers with PCT or cluster workers with MDCS) have no visible graphics of their own. However, they can generate off-screen graphics and call 'print' to files.
Niels
2015 年 3 月 6 日
編集済み: Niels
2015 年 3 月 6 日
Hi Edric, I am trying to run a slightly modified script:
a = linspace(0,10);
parfor ii=1:10
for jj=1:length(a)
x(ii,jj) = rand;
end
end
However, Matlab complains about the x variable classification. But I don't quite understand, why it shouldn't work. Any ideas? Thanks in advance, Niels.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!