Display progress, pause or stop a time-consuming loop

버전 1.3.0.0 (93.8 KB) 작성자: Rafael Oliveira
Allows you to display a loop’s progress, pause (and also change related code) or stop it.
다운로드 수: 818
업데이트 날짜: 2012/2/17

라이선스 보기

편집자 메모: This file was selected as MATLAB Central Pick of the Week

This class creates a small pause/stop window, that allows you to either abort a running loop or pause the execution and create breakpoints or change/correct mistakes in the code (this works for files that are not in the stack from where stop.requested is called).

It can be used in different ways:
- Control the loop execution:
while ~stop.requested
%do your heavy calculations here
end
stop.close;

- abort execution in the middle
for i = 1:100
%do your heavy calculations here
if stop.requested
stop.close;
error('Stop requested')
end
end

- inform the current progress
iter = 1;
maxIter = 1000;

while iter<maxIter || stop.requested
%do your heavy calculations here
progress = iter/maxIter;
stop.setStatus('Running...',progress);
end
stop.close;

In loops with many iterations, you can also avoid updating the screen too often (and reduce the impact of calling stop.request), by calling: stop.requested(num); where num is the interval on which the gui will be refreshed to check for user interaction.

And to enable the easter egg (xkcd.com/1017/), use:
stop.setStatus('xkcd', progress);

인용 양식

Rafael Oliveira (2024). Display progress, pause or stop a time-consuming loop (https://www.mathworks.com/matlabcentral/fileexchange/35074-display-progress-pause-or-stop-a-time-consuming-loop), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2011b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Desktop에 대해 자세히 알아보기
도움

줌: xkcd1930

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.3.0.0

Added easter egg: xkcd.com/1017/

1.1.0.0

14/02/2012 - Corrected the stop.close behavior

1.0.0.0