MATLAB中小数取整的函数有4个:floor、ceil、round、fix
(1)floor:向下取整
>> floor(1.4)
ans =
1
>> floor(2.6)
ans =
2
>> floor(-2.3)
ans =
-3
(2)ceil:向上取整
>> ceil(2.1)
ans =
3
>> ceil(-2.3)
ans =
-2
(3)round:四舍五入取整
>> round(0.4)
ans =
0
>> round(0.5)
ans =
1
>> round(-1.3)
ans =
-1
(4)fix:向零取整
>> fix(1.9)
ans =
1
>> fix(-1.9)
ans =
-1
>> fix(2.9)
ans =
2
>> fix(-2.9)
ans =
-2