STOPLOOP (v1.0, jun 2008)

Shows stop button to interrupt loops
5,2K Downloads
Aktualisiert 26. Jun 2008

Lizenz anzeigen

STOPLOOP - creates stop button to have a user interrupt a loop

FS = STOPLOOP creates a message box window and returns a structure FS that
holds two functions, called FS.Stop and FS.Clear. The function FS.Stop()
will return true, if the OK button has been clicked (or the message box
has been removed), so that a loop can be interrupted.

The function FS.Clear() can be used to remove the message box, if a loop has ended without user interruption.

FS = STOPLOOP(STR) uses the string STR to display instead of the default
'Stop the Loop'.

Example:
tic ; % We will measure elapsed time in a loop
% Set up the stop box:
FS = stoploop({'Stop me before', '5 seconds have elapsed'}) ;
% Display elapsed time
fprintf('\nSTOPLOOP: elapsed time (s): %5.2f\n',toc)
% start the loop
while(~FS.Stop() && toc < 5), % Check if the loop has to be stopped
fprintf('%c',repmat(8,6,1)) ; % clear up previous time
fprintf('%5.2f\n',toc) ; % display elapsed time
end
FS.Clear() ; % Clear up the box
clear FS ; % this structure has no use anymore

Version 1.0, jun 2008
Inspired by several posts on the FEX on "how to interrupt a loop?".

Zitieren als

Jos (10584) (2024). STOPLOOP (v1.0, jun 2008) (https://www.mathworks.com/matlabcentral/fileexchange/20455-stoploop-v1-0-jun-2008), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R14SP1
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Graphics Objects finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.0.0