Progress Bar in Live Editor and Output in Console
Dear Friends of Matlab,
I love the new possibilities offered by Live Editor. However, when it comes to real-life usage, in situations beyond compiling a high-school homework, Live Editor seems—at least to me—to still have some limitations.
The thing that bothers me most of all is that I cannot find a way to print to the console. This would be extremely valuable to display debug and monitor information about the status of the computation. Not all computations can be completed in a few seconds!
In the past I have been using a function of mine, drawing from Monitoring Progress of a Calculation by Loren Shure, which uses escape characters, such as \b for backspace, to control where the output goes.
I would like to be able to use it in the Live Editor too.
All my (many) attempts have failed so far. If I embed this code in the Live Editor
for idx = 0:100 pause(0.1) % 100 ms pause progressbar(idx); % prints the progress bar showing idx% completion end
it correctly works, showing the progress bar advancing. However, all my real applications use a similar code from within some script function ".m" rather then in the Live Editor. When used in script files, the output in the Live Editor is not updated anymore until the very end when it then suddenly shows 100% completion. But at that point it is already too late.
- Does anyone know how to refresh the Live Editor forcing it to flush the text out?
- Alternatively, I would also consider it as a good solution to print the progress bar directly in the console. Does anyone know how to force Matlab to print in the console from the Live Editor? Some java undocumented trick?
I am much looking forward to hearing from your ideas.