How to use parfor function to update a 2d array

14 ビュー (過去 30 日間)
Ammar Malick
Ammar Malick 2020 年 8 月 24 日
コメント済み: Ammar Malick 2020 年 8 月 24 日
Hi,
I am currenty using a 2d array to run some surface propogation algorithms. My current implementation of nested for loops is too time consuming and I heard that parfor can help speed up this task as the update function does not depend on the new output values of the function. Basically my current code is structured as follows:
for i=1:30
for j=1:30
phi(i,j)=f(i,j) %Compute the function value based on the current position
end
end
I was wondering if changing the first for loop to parfor will retain the functionality of my code:
parfor i=1:30
for j=1:30
phi(i,j)=f(i,j) %Compute the function value based on the current position
end
end
Is this a correct implementation of a parfor loop for my implementation?

採用された回答

Raymond Norris
Raymond Norris 2020 年 8 月 24 日
Hi Ammar,
As you've written, yes, this will work fine. Reference this doc for any troubleshooting.
Raymond
  1 件のコメント
Ammar Malick
Ammar Malick 2020 年 8 月 24 日
Thank you for your prompt response Raymond.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by