Matlab中常用的取整函数
xhHuang, HPCL
Matlab中常用的取整函数有四个,
1、floor(x)
向下取整函数
floor(1.2) = 1
floor(1.7) = 1
floor(-1.7) = -2
2、ceil(x)
向上取整函数
ceil(1.2) = 2
ceil(1.7) = 2
ceil(-1.3) = -1
3、round(x)
取最接近整数,如果小数部分是0.5,则向绝对值大的方向取整
round(1.3) = 1
round(1.5) = 2
round(-1.2) = -1.2
round(-1.5) = -2
4、fix(x)
向0取整
<span style="font-size:14px;">fix(1.2) = 1
fix(1.7) = 1
fix(-1.2) = -1
fix(-1.8) = -1</span>
Thanks.