zoukankan      html  css  js  c++  java
  • 【转】 MATLAB中取整函数(fix, floor, ceil, round)的使用

    MATLAB取整函数
    2010-05-23 22:10

    1)fix(x) : 截尾取整.

    >> fix( [3.12 -3.12])

    ans =

         3    -3
    (2)floor(x):不超过x 的最大整数.(高斯取整)

    >> floor( [3.12 -3.12])

    ans =

         3    -4

    (3)ceil(x) : 大于x 的最小整数

    >> ceil( [3.12 -3.12])

    ans =

         4    -3

    (4)四舍五入取整

    >> round(3.12 -3.12)

    ans =

         0

    >> round([3.12 -3.12])

    ans =

         3    -3

    MATLAB中四个取整函数具体使用方法如下:

    Matlab取整函数有: fix, floor, ceil, round.
    fix
    朝零方向取整,如fix(-1.3)=-1; fix(1.3)=1;
    floor
    朝负无穷方向取整,如floor(-1.3)=-2; floor(1.3)=1;
    ceil
    朝正无穷方向取整,如ceil(-1.3)=-1; ceil(1.3)=2;
    round
    四舍五入到最近的整数,如round(-1.3)=-1;round(-1.52)=-2;round(1.3)=1;round(1.52)=2。
  • 相关阅读:
    array_merge
    漏斗模型
    3 破解密码,xshell连接
    2-安装linux7
    1-Linux运维人员要求
    17-[模块]-time&datetime
    16-[模块]-导入方式
    Nginx服务器
    15-作业:员工信息表查询
    14-本章总结
  • 原文地址:https://www.cnblogs.com/lcxu2/p/2004004.html
Copyright © 2011-2022 走看看