format函数使用matlab,matlab基本函数-凯发k8官方网
1、format函数:控制输出、显示格式
2、用法说明
format 缺省格式,同short。matlab中常用的显示格式有:
(1)format short表示5位近似定点数
(2)format long 15位近似定点数
(3)format hex 十六进制表示
(4)format bank 银行格式,固定元和分
(5)format rat 最小证书比例(分数)表示
3、用法举例
>> pi
ans =
3.1416
>> format
>> pi
ans =
3.1416
>> format short
>> pi
ans =
3.1416
>> format long
>> pi
ans =
3.141592653589793
>> format hex
>> pi
ans =
400921fb54442d18
>> format bank
>> pi
ans =
3.14
>> format rat
>> pi
ans =
355/113
4、附录
>> help format
format set output format.
format with no inputs sets the output format to the default appropriate
for the class of the variable. for float variables, the default is
format short.
format does not affect how matlab computations are done. computations
on float variables, namely single or double, are done in appropriate
floating point precision, no matter how those variables are displayed.
computations on integer variables are done natively in integer. integer
variables are always displayed to the appropriate number of digits for
the class, for example, 3 digits to display the int8 range -128:127.
format short and long do not affect the display of integer variables.
format may be used to switch between different output display formats
of all float variables as follows:
format short scaled fixed point format with 5 digits.
format long scaled fixed point format with 15 digits for double
and 7 digits for single.
format shorte floating point format with 5 digits.
format longe floating point format with 15 digits for double and
7 digits for single.
format shortg best of fixed or floating point format with 5
digits.
format longg best of fixed or floating point format with 15
digits for double and 7 digits for single.
format shorteng engineering format that has at least 5 digits
and a power that is a multiple of three
format longeng engineering format that has exactly 16 significant
digits and a power that is a multiple of three.
format may be used to switch between different output display formats
of all numeric variables as follows:
format hex hexadecimal format.
format the symbols , - and blank are printed
for positive, negative and zero elements.
imaginary parts are ignored.
format bank fixed format for dollars and cents.
format rat approximation by ratio of small integers. numbers
with a large numerator or large denominator are
replaced by *.
format may be used to affect the spacing in the display of all
variables as follows:
format compact suppresses extra line-feeds.
format loose puts the extra line-feeds back in.
example:
format short, pi, single(pi)
displays both double and single pi with 5 digits as 3.1416 while
format long, pi, single(pi)
displays pi as 3.141592653589793 and single(pi) as 3.1415927.
format, intmax('uint64'), realmax
shows these values as 18446744073709551615 and 1.7977e 308 while
format hex, intmax('uint64'), realmax
shows them as ffffffffffffffff and 7fefffffffffffff respectively.
the hex display corresponds to the internal representation of the value
and is not the same as the hexadecimal notation in the c programming
language.
see also disp, display, isnumeric, isfloat, isinteger.
reference page in help browser
doc format
总结
以上是凯发k8官方网为你收集整理的format函数使用matlab,matlab基本函数-format函数的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇:
- 下一篇: