I've got a Matlab function that takes some time to run, and I'd like to show the user that progress is being made. Just disp
ing the progress every 5% or so would clutter the screen too much, as the previous text would not be erased.
How can this problem be solved? There's other important information in the command window, so clearing it is out of the question.
You can use
waitbar
function for that. See MATLAB Documentation on waitbar.check this out: http://www.mathworks.com/matlabcentral/fileexchange/3607-progressbar and http://www.mathworks.com/matlabcentral/fileexchange/26773-progress-bar
Basically what is written by @Ergodicity is correct, just for Octave if you set the standard output to be buffered (which is default btw), you had to enable it by page_output_immediately(1); see this page for more octave doc: Terminal output
a very brief modifications on the proposed code:
Showing the progess in the Command Window is also possible (and maybe easier). I found a very simple, fast to implement solution on http://undocumentedmatlab.com/blog/command-window-text-manipulation/.
If you embedd this code the command line is showing (for example): "Percent done: 27.8" without entering a newline every iteration!