matlab程序format,format——MATLAB

format:设置输出格式

对浮点性变量,缺省为format short.

format并不影响matlab如何计算和存储变量的值。对浮点型变量的计算,即单精度或双精度,按合适的浮点精度进行,而不论变量是如何显示的。对整型变量采用整型数据。整型变量总是根据不同的类(class)以合适的数据位显示,例如,3位数字显示显示int8范围 -128:127。

format short, long不影响整型变量的显示。

format long 显示15位双精度,7为单精度(scaled fixed point)

format short 显示5位(scaled fixed point format with 5 digits)

format short eng 至少5位加3位指数

format long eng 16位加至少3位指数

format hex 十六进制

format bank 2个十进制位

format + 正、负或零

format rat 有理数近似

format short 缺省显示

format long g 对双精度,显示15位定点或浮点格式,对单精度,显示7位定点或浮点格式。

format short g 5位定点或浮点格式

format short e 5位浮点格式

format long e 双精度为15位浮点格式,单精度为7为浮点格式

FORMAT Set output format.

FORMAT with no inputs sets the ouput 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 SHORT E Floating point format with 5 digits.

FORMAT LONG E  Floating point format with 15 digits for double and

7 digits for single.

FORMAT SHORT G Best of fixed or floating point format with 5 digits.

FORMAT LONG G  Best of fixed or floating point format with 15 digits

for double and 7 digits for single.

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.

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.14159265358979 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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值