matlab-經常使用函數(2)

matlab取整函數:函數

  • floor()

   floor()函數爲向下取整函數,以下:
spa

floor(0.5)
ans=
        0

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

   ceil()函數爲向上取整,以下: blog

 

ceil(0.5)
ans=
        1

ceil(-0.5)
ans=
        0

 

  • round()

   round()函數的值始終趨於遠離0點,以下:class

 

round(0.5)
ans=
        1

round(-0.5)
ans=
        -1

 

  • fix()

   fix()函數的值始終趨於靠近0點,以下:di

fix(0.5)
ans=
        0

fix(-0.5)
ans=
        0
相關文章
相關標籤/搜索