I'm curious about the progress of the running program and I print some information about the current iteration such as:
for i = 1:N
...
...
msg = sprintf('Processed %d/%d', i, N);
display(msg)
end
I don't want to print the progress on separate lines, instead, I want the last line to replace the previous one. I don't want to use clc
which clears all the content.
I know that ''
can clear the last character (like backspace) and I can create a function with a for loop which clears the items till the previous new line before the last. But is there a better way to do that? If not, how can I check whether the last character on the command line is a new line or not?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…