I have a program in Octave that has a loop - running a function with various parameters, not something that I can turn into matrices. At the beginning of each iteration I p
As mentioned by moastab, fflush(stdout)
works for Octave.
In MATLAB, use drawnow('update')
to flush the output.
MATLAB's drawnow
function will be familiar to those who control the redrawing of graphical objects in MATLAB, but it applies to the stdout stderr buffers as well. The 'update'
option is not required, but limits the flushing to non-graphical queues. This detail is merely implied in the drawnow() documentation; I have verified it to work on fprintf calls in a loop.