在 matlab 中是否可以明确格式化输出数字? [英] Is it possible in matlab to explicitly format the output numbers?
问题描述
我知道 MATLAB 的 format long、format short、eng ... 等等.但 short 和 long 将始终显示预定义的小数位数,并带有指数,例如,format bank 将始终显示 2 位小数.
I know about MATLAB's format long, format short, eng ... and so on. But short and long will always display a predefined number of decimals, with an exponent, and for example, format bank will display always 2 decimals.
是否可以选择以fortran 方式"放置显式格式,例如 f8.3 --> 1234.678 ?
Is there an option to put your explicit format, in a "fortran way", like f8.3 --> 1234.678 ?
我正在寻找一种方法来显示带有 4 个小数点的数字,其余的在小数点之前,没有指数.
I'm looking for a way to display numbers with 4 decimal points, and the rest ahead of the decimal point, with no exponent.
推荐答案
我不知道有什么方法可以指定所需类型的全局格式.sprintf('%15.4f', x)
或 num2str(x, '%15.4f')
做你想要的,如果你不介意打电话他们每次都明确.
I don't know of a way to specify a global format of the type you want. sprintf('%15.4f', x)
or num2str(x, '%15.4f')
do what you're looking for, if you don't mind calling them explicitly each time.
这篇关于在 matlab 中是否可以明确格式化输出数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!