在Matlab中是否可以显式格式化输出数字? [英] Is it possible in matlab to explicitly format the output numbers?
问题描述
我了解MATLAB的 format long , format short , eng ... 等.但是short和long将始终显示预定义的小数位数,并带有指数,例如,格式库将始终显示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屋!