Variable to track parfor loop progress

조회 수: 17 (최근 30일)
Andreu Angles Castillo
Andreu Angles Castillo 2018년 12월 18일
답변: Edric Ellis 2018년 12월 19일
I am using a paralled program and i would like to keep track of the progress of the loop, each iteration takes more or less the same time to execute. I came up with the following solution.
i=0;
parfor j=0:max
sprintf('%f',i);
some_calculation(j);
i=i+1;
end
I know I cannot use a variable in this way, but I believe the variable "i" could be used without any trouble in this way. Any work around?
Thanks, Andreu

답변 (2개)

Edric Ellis
Edric Ellis 2018년 12월 19일
@Matt J posted the simplest option which is to have the parfor loop display data. If you need more sophistication, you can use DataQueue to perform arbitrary computations at the client as the loop progresses, such as displaying a waitbar.

Matt J
Matt J 2018년 12월 18일
What I do is display the loop counter, like in the following
parfor j=0:Jmax
some_calculation(j);
j,
end

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by