如何配置 Octave 终端输出没有科学计数法的数字?

How to configure Octave terminal to output numbers without scientific notation?

我正在尝试在 Octave 终端中打印一长串 table 数字。

disp(vec);

我得到了什么

7.0931e-01
6.2041e-05
9.7740e-01
9.9989e-01
8.8428e-01
9.0524e-01
...

这样的数字符号读起来很痛苦。如何设置 Octave 终端正常输出数字 0.7, 0.014, 0.95?

你可以用format short g来显示每个数字更符合逻辑的格式

format short g
disp(vec)

%     0.70931
%  6.2041e-05
%      0.9774
%     0.99989
%     0.88428
%     0.90524

在这种情况下使用 'fprintf' 可能会有所帮助

a=0.0001234;
fprintf('%.3f\n',a)

但这里的限制是小数点的数量是固定的,所以在某些数字中它会在末尾显示零,而对于某些数字它可能会截断数字。