MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   MATLAB舍入函数-如何向上或向下舍入.5? (https://www.labfans.com/bbs/showthread.php?t=23832)

poster 2019-12-10 20:48

MATLAB舍入函数-如何向上或向下舍入.5?
 
MATLAB的舍入函数如何与.5一起使用?像5.5吗?是四舍五入还是四舍五入?讨论此功能的Mathworks页面对此一无所获,该示例也无济于事!

这是MATLAB round函数的mathworks页面:

[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/round.html"]mathworks圆形函数页面[/URL]



[B]回答:[/B]

[URL="http://en.wikipedia.org/wiki/MATLAB#Variables"]维基百科[/URL]知道:
[INDENT] round(X):四舍五入到最接近的整数,后跟5个舍入到最接近[B]0的整数[/B] 。例如,round(2.5)返回3; round(-2.5)返回-3。

[/INDENT]关于[URL="http://en.wikipedia.org/wiki/Rounding"]舍入[/URL]的文章中有关于此方案的更多信息(从零[URL="http://en.wikipedia.org/wiki/Rounding"]舍入[/URL]一半),还有许多其他信息。



[url=https://stackoverflow.com/questions/3597197]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 01:05

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.