Comments on: Displaying the Progress of a Long Running MATLAB Script, Part 1: fprintf https://blogs.mathworks.com/videos/2015/08/06/displaying-the-progress-of-a-long-running-matlab-script-part-1-fprintf/?s_tid=feedtopost Stuart uses video to share his experiences solving problems with MATLAB day-to-day, interesting new features, plus tips and tricks he has picked up along the way. Mon, 17 Aug 2015 16:22:38 +0000 hourly 1 https://wordpress.org/?v=6.2.2 By: Julian https://blogs.mathworks.com/videos/2015/08/06/displaying-the-progress-of-a-long-running-matlab-script-part-1-fprintf/#comment-54809 Mon, 17 Aug 2015 16:22:38 +0000 https://blogs.mathworks.com/videos/?p=1680#comment-54809 While I have been using techniques such as you describe for many years it was useful to learn that I can use fprintf without a file identifier to send output to the screen! I have always used fprintf(1, …) to send to stdout and fprintf(2, …) to send to stderr. I never noticed this new feature when it was introduced… I guess it explains all those mlint messages “This call of fprintf will produce output that will be printed”, which always had me scratching my head.

]]>
By: Stuart McGarrity https://blogs.mathworks.com/videos/2015/08/06/displaying-the-progress-of-a-long-running-matlab-script-part-1-fprintf/#comment-54642 Mon, 10 Aug 2015 14:12:42 +0000 https://blogs.mathworks.com/videos/?p=1680#comment-54642 Yes, that is a useful technique.

]]>
By: Sean de Wolski https://blogs.mathworks.com/videos/2015/08/06/displaying-the-progress-of-a-long-running-matlab-script-part-1-fprintf/#comment-54641 Mon, 10 Aug 2015 13:50:36 +0000 https://blogs.mathworks.com/videos/?p=1680#comment-54641 I like to use ‘\b’ in “fprintf” to keep the iteration updates in one place rather than chewing through the command window.

n = 1000;

fprintf(1,'Processing %04i, of %i\n',0,n);      
for ii = 1:n
    fprintf(1,'\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b %04i, of %i\n',ii,n);      
    pause(0.01)
end
]]>