matlab-常用函数(2)

matlab取整函数:

  • floor()

   floor()函数为向下取整函数,如下:

floor(0.5)
ans=
        0

floor(-0.5)
ans=
        -1
  • ceil()

   ceil()函数为向上取整,如下:

 

ceil(0.5)
ans=
        1

ceil(-0.5)
ans=
        0

 

  • round()

   round()函数的值始终趋于远离0点,如下:

 

round(0.5)
ans=
        1

round(-0.5)
ans=
        -1

 

  • fix()

   fix()函数的值始终趋于靠近0点,如下:

fix(0.5)
ans=
        0

fix(-0.5)
ans=
        0

 

posted @ 2017-06-16 21:09  Mr-Tiger  阅读(648)  评论(0编辑  收藏  举报