how to write a program to round numbers

4 次查看(过去 30 天)
Hi
how to write a proggram to round numbers whitout a prepared command in matlab like (round)

回答(1 个)

Jan
Jan 2019-1-23
编辑:Jan 2019-1-23
Rounding is the same as adding 0.5 and cropping the fractional part of the number.
For negative numbers you have to subtract 0.5.
To remove the fractional part, floor, ceil, fix and rem(x,1) can help.

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by