필터 지우기
필터 지우기

Break point in parfor loop

조회 수: 4 (최근 30일)
Yoav Livneh
Yoav Livneh 2011년 5월 17일
I am trying to find a way to include a cancel button to a code that uses PARFOR. I tried using the same technique used in regular FOR loops (like the cancel button in WAITBAR) but a PARFOR loop cannot contain commands like BREAK or RETURN. Is there a way around this?
Thanks.
  댓글 수: 2
Andy
Andy 2011년 5월 17일
Are you trying to cancel the operation part way through (like with Ctrl+C)? Or are you trying to duplicate functionality like:
for ix=1:10
if ix == 6
break
end
end
If the latter, keep in mind (from the documentation of parfor): "Note: Because of independence of iteration order, execution of parfor does not guarantee deterministic results." The reason parfor cannot contain break or return is because of this independence of iteration order.
Yoav Livneh
Yoav Livneh 2011년 5월 18일
I am trying to cancel the operation part way through, exactly like Ctrl+C.

댓글을 달려면 로그인하십시오.

답변 (1개)

Arturo Moncada-Torres
Arturo Moncada-Torres 2011년 5월 18일
Quan Quach has an excellent tutorial regarding this issue. I think href=""<http://blinkdagger.com/matlab/matlab-gui-tutorial-how-to-stop-a-long-running-function/</a> this> may solve your problem.
Regards,
Arturo M.
  댓글 수: 1
Yoav Livneh
Yoav Livneh 2011년 5월 18일
Thanks for the answer. This does look like an elegant solution but how do I incorporate this into a parfor loop?

댓글을 달려면 로그인하십시오.

카테고리

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