我在Octave(Matlab模拟)中有一段代码如下:
c = 1;
for y = 1:rows
for x = 1:cols
printf('%d ', c);
if (mod(c,10)==0)
printf('\n');
end
c++;
% some calculations here
end
end
我显然希望计数器值C的实时输出知道该过程的进展情况。但它似乎不起作用。所有输出都出现在整个程序完成的最后。将printf
更改为disp
也无济于事。
我的问题是为什么会这样?