File Exchange

image thumbnail

fprintf_r - Carriage Return without Linefeed

version 1.0 (2.07 KB) by

For the MATLAB Command Window as replacement of fprintf('\r') which does not work on Windows XP.



View License

Matlab function for doing a carriage return (without linefeed!) followed by some output using fprintf.

This is useful, e.g. to replace the display of a counter i in the style:
fprintf('\r %f',i), because the \r format is not working properly on windows systems.

Input is a string s and a variable x which are forwarded to the fprintf command as fprintf(s,x). Use a vector for x in case you want to display several variables at once.

In the first call of this function, nothing else is done. Starting with the second call, the corresponding number of backspaces is inserted before executing fprintf(s,x), so the output starts at the place it would have started without the first fprintf command.

If 'reset' is given as the 3rd argument, the script deals with s and x as in the first call of the function.

If 'reset' is given as the 1st and only argument, the next call will be treated as a "first" call, again.

    fprintf_r(s, x[, 'reset']) or

    for i = 1:110
      fprintf_r('%i', i);

N.B: This function is not necessary on UNIX systems, as \r is working fine there.

Comments and Ratings (1)


Only used the basic functionality, but it's pretty cool.


MATLAB Release
MATLAB 7.4 (R2007a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video