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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by