fprintf_r - Carriage Return without Linefeed

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

이 제출물을 팔로우합니다

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.

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

EXAMPLE:
for i = 1:110
fprintf_r('%i', i);
pause(0.05)
end
fprintf_r('reset')

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

인용 양식

Florian Dignath (2026). fprintf_r - Carriage Return without Linefeed (https://kr.mathworks.com/matlabcentral/fileexchange/27903-fprintf_r-carriage-return-without-linefeed), MATLAB Central File Exchange. 검색 날짜: .

카테고리

Help CenterMATLAB Answers에서 Programming에 대해 자세히 알아보기

일반 정보

MATLAB 릴리스 호환 정보

  • R2011b 이상 릴리스와 호환

플랫폼 호환성

  • Windows
  • macOS
  • Linux
버전 퍼블리시됨 릴리스 정보 Action
1.1.0.0

nargchk replaced by narginchk for compatibility with new MATLAB releases.

1.0.0.0

This script is still useful on Windows 7-10 because fprintf('\r') does still not work there.