Matlab 里面floor, ceil, fix 和 round函数

作者 mousepotato 发布时间 2011-05-02 17:49 文章分类 Research 文章评论 抢沙发 阅读次数 1405 views

floor:朝负无穷方向舍入
B = floor(A) rounds the elements of A to the nearest integers less than or equal to A.
ceil:朝正无穷方向舍入
B = ceil(A) rounds the elements of A to the nearest integers greater than or equal to A.
fix:朝零方向舍入
B = fix(A) rounds the elements of A toward zero, resulting in an array of integers.
round:四舍五入
B = round(A) rounds the elements of X to the nearest integers.
Example:

a= [-0.9,    -2.1,    -0.4,    0.3,    0.8,    1.1,    2.7,    -1.2+2.9i];

floor(a)=[ -1,      -3,      -1,      0,      0,      1,      2,       -2+2i]

ceil(a)= [ 0,       -2,       0,      1,      1,      2,      3,       -1+3i]

fix(a)= [ 0,       -2,       0,      0,      0,      1,      2,       -1+2i]

round(a)=[-1,       -2,       0,      0,      1,      1,      3,       -1+3i]

注:For complex X, for all the four fuctions the imaginary and real parts are rounded independently.

本文固定链接: http://anotherbug.com/blog/2011/05/matlab-%e9%87%8c%e9%9d%a2floor-ceil-fix-%e5%92%8c-round%e5%87%bd%e6%95%b0/ | 爱凝依依

该日志由 于2011年05月02日发表在 Research 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: Matlab 里面floor, ceil, fix 和 round函数 | 爱凝依依
关键字:

发表评论

快捷键:Ctrl+Enter