Progress Bar in Live Editor and Output in Console

16 views (last 30 days)
Andrea
Andrea on 29 Mar 2018
Answered: Arwel on 10 Feb 2019

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.

  1. Does anyone know how to refresh the Live Editor forcing it to flush the text out?
  2. 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.

Answers (1)

Arwel
Arwel on 10 Feb 2019
Me too - I have exactly the same problem. In my case and 'fminsearch' that takes a few minutes, so appears to make the live editor 'hang' for that time until suddenly printing everything out at the end. If it was still giving iteration updates in the console that would be one thing, but to actually not give any real indication bar the useless 'calculating' box in the top left corner makes this unusable for me for any serious work unless there is a workaround. Mind you, I'm trying this on 2016b, I'm hoping updating to 2018b might be better....

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!