How to show the progress of a program without using disp()?
7 views (last 30 days)
Show older comments
Recently, I've been running several large programs that would take many days to finish. It's very important for me to know the progress of the program, so that I know it is not stuck somewhere.
What is the best way to show the progress? I tried to use disp(i), but it obviously slows down the program. Is there a better way to achieve this?
0 Comments
Accepted Answer
Walter Roberson
on 27 Aug 2018
waitbar() is a common way to show progress.
However, remember that waitbar() uses resources too, so using disp() selectively can be more efficient. For example instead of disp(i) you might have
if mod(i, 50) == 0; disp(i); end
or
if mod(i, 10) == 0; fprintf('.'); end; if mod(i, 500) == 0; fprintf('\n'); end
2 Comments
Walter Roberson
on 28 Aug 2018
mod() is not the fastest operation, but it is not bad.
My tests show that it is possible to do slightly better if you are willing to test at powers of 2 instead of using decimal:
mod(A_Double, A_Double)
is just slightly slower than
bitand(A_uint16, A_uint16)
for example,
u63 = uint16(63);
for K = uint16(1:30000)
...
if ~bitand(K, u63) ...
end
end
would be true at multiples of 64.
More Answers (0)
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!