loopCount(i,n)

Simple command line progress information for “for” loops
20 Downloads
Updated 26 Jun 2018

View License

Displays progress information for “for” loops at the command window.
Takes inputs: i is current iteration and n is total number of iterations
NOTE: Call tic before loop and loopCount(i,n) before loop end
• Displays the current iteration out of the total to command window
• Also displays the time elapsed and time remaining.
• Times given in seconds, minutes or hours to aid clarity
• Gives update every 5 seconds
EXAMPLE:
>> n=3; w=6; tic;
>> for i=1:n
>> pause(w);
>> loopCount(i,n);
>> end
Outputs on the command line:
Completed iteration 1 of 3
. Time elapsed: 6 seconds. Time remaining: 12 seconds
Completed iteration 2 of 3
. Time elapsed: 12 seconds. Time remaining: 6 seconds
Completed all 3 iterations in 18 seconds

Cite As

Jody Muelaner (2024). loopCount(i,n) (https://www.mathworks.com/matlabcentral/fileexchange/67842-loopcount-i-n), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Loops and Conditional Statements in Help Center and MATLAB Answers
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0.0