loopCount(i,n)
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
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |