【求助】在matlab里面怎么取一个数与之最相近的一个整数?
怎样把小数取之与其最相近的整数?谢谢! 如果是四舍五入的话,就用round吧。比如:
>> f=round(0.01)
f =
0
>> f=round(-0.05)
f =
0
>> f=round(0.78)
f =
1 根据不同的需求有好几个呢?在MATLAB帮助中查ROUND看相关链接就行了。
回复 #2 yqing 的帖子
关于Matlab里取整的函数FLOOR Round towards minus infinity.
FLOOR(X) rounds the elements of X to the nearest integers
towards minus infinity.
ROUND Round towards nearest integer.
ROUND(X) rounds the elements of X to the nearest integers.
CEIL Round towards plus infinity.
CEIL(X) rounds the elements of X to the nearest integers
towards infinity.
FIX Round towards zero.
FIX(X) rounds the elements of X to the nearest integers
towards zero.
页:
[1]