Using the parfor loop to minimize a function
7 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am completely new to MATLAB's parallel computing and I didn't know how to convert my for loop into a parfor loop. I have a function f which I would like to evaluate at 10000 different values in vector A. My laptop has 6 processors that I would like to use simultaneously to divide the task because evaluating my function is very time-consuming. So, here is how my simplified problem looks like:
A=[]; %a 10 by 6 matrix of parameter values
eval=zeros(10000,1;)
for t=1:10000
eval(t)=f(A(t,:));
end
Can you help me rewrite this for a parfor loop?
Thanks in advance!
George
0 件のコメント
回答 (1 件)
Rajanya
2024 年 11 月 21 日 11:54
The MATLAB documentation of 'parfor' covers how to convert ‘for’ loops into ‘parfor’ loops. You can either search for it by entering the following command in the MATLAB Command Window,
doc parfor
Or you can visit the below link:
Thanks!
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!