• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

format——MATLAB

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap