Extended version of the idea Loren described here:
Say you have a loop that's running for a while. You're not sure whether it's worth getting a cup of coffee or not, so you display the current iteration using "disp(i)". At some point you're Matlab console is flooded with numbers, that's annoying. Especially if your loop does also display warnings. That's where this function comes to play. You just display the iteration using
In contrast to other contributions I found, this code is able to handle multiple lines of continuously updated text and has a basic plotting capabilities:
writeConsoleCont(); % initialization - always execute this first
for k = 0:100
writeConsoleCont(k); % numerical data
writeConsoleCont("Some text and plot", k, k^2);
Tom DeLonge (2020). writeConsoleCont(text,varargin) (https://www.mathworks.com/matlabcentral/fileexchange/63778-writeconsolecont-text-varargin), MATLAB Central File Exchange. Retrieved .
@Chang: yes, indeed, this function works only for calls from within a function.
@Stephen: Thank you for your input, I will compare them.
the bug is that everything is normal for the 1st run,
then it begins to show counter at same line as testing script on 2nd run ...
one of the differences of this submission to other previous ones is that it has a very unique bug :)
What does this submission do that is different to the existing submissions with the same functionality?:
and no doubt many others.
Added more documentation on where it differs from other's contributions...
Inspired by: Overwritable message outputs to commandline window