Displaying information from MATLAB without a line feed

让人想犯罪 __ 提交于 2019-12-03 10:09:35

The fprintf function does not add a line feed unless you explicitly tell it to. Omit the fid argument to have it print to the Command Window.

fprintf('Doing stuff... ');
for i = 1:5
    fprintf('%d ', i);
    % do some work on that pass...
end
fprintf(' done.\n'); % That \n explicitly adds the linefeed

Using sprintf won't quite work: it creates a string without a line feed, but then if you use disp() or omit the semicolon, disp's own display logic will add a line feed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!