how to write a program to round numbers

조회 수: 5 (최근 30일)
farid khalafi
farid khalafi 2019년 1월 23일
편집: Jan 2019년 1월 23일
Hi
how to write a proggram to round numbers whitout a prepared command in matlab like (round)
  댓글 수: 2
Stephen23
Stephen23 2019년 1월 23일
farid khalafi
farid khalafi 2019년 1월 23일
I want to write rounding program (in any way)
I want to know ... how round command works?

댓글을 달려면 로그인하십시오.

답변 (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