可以打印退格字符(
\b
)将光标向后移动。似乎它可能覆盖了前面的字符,但在我的上面却没有。所以如下所示:
printf ("processing ");
for i = 1:3
for i = 1:9
printf (".");
pause (0.1);
endfor
printf (repmat ("\b", 1, 9));
printf (repmat (" ", 1, 9));
printf (repmat ("\b", 1, 9));
endfor
printf ("\n");
或者,你可以安装八度锻造
miscellaneous package
,这是
text_waitbar
功能:
pkg load miscellaneous;
text_waitbar (0, 70); # set length of waitbar
text_waitbar (0.0, "processing ");
for i = 1:3
for i = 1:9
text_waitbar (i/9, "processing");
pause (0.1);
endfor
endfor
会是这样的:
[############################################ ] 80%