fix

rounds the elements of A toward zero, resulting in an array of integers. For complex A, the imaginary and real parts are rounded independently.

将 A 的元素舍入为零, 从而生成整数数组。对于复数的 A, 实部和虚部是独立地四舍五入。

a = [-1.9, -0.2, 3.4, 5.6, 7.0, 2.4+3.6i]

a =
  Columns 1 through 4 
  -1.9000        -0.2000        3.4000        5.6000          

  Columns 5 through 6 
   7.0000        2.4000 + 3.6000i

fix(a)

ans =
  Columns 1 through 4 
  -1.0000        0             3.0000        5.0000          

  Columns 5 through 6 
   7.0000        2.0000 + 3.0000i

1)fix(n)的意义是取小于n的整数(是向零点舍入的意思是往零的方向上靠),这是一类应用在整数取值上的函数,就如同以前我们所研究的求整问题,
例如,fix(pi)=3;fix(3.5)=3;fix(-3.5)=-3;我这样举例的意思是说明这与四舍五入无关,就是纯粹的一种取值函数。下面讲到各类时我都会举例子,注意区分!

2)round(n)的意思是纯粹的四舍五入,意思与我们以前数学中的四舍五入是一样的!
round(pi)=3;round(3.5)=4;round(-3.5)=-4;round(-3.1)=-3;这一点注意与fix所产生的不同,注意区分!

3)ceil(n)的意思是向正方向舍入,这一点要与floor(n)向负方向舍入一起讲,能够更好的区分,举例说明吧

ceil(pi)=4; ceil(3.5)=4; ceil(-3.2)=-3;向正方向舍入

floor(pi)=3; floor(3.5)=3; floor(-3.2)=-4;向负方向舍入
原文地址:https://www.cnblogs.com/xiaoxuesheng993/p/7465956.html