how to write a program to round numbers

12 visualizaciones (últimos 30 días)
farid khalafi
farid khalafi el 23 de En. de 2019
Editada: Jan el 23 de En. de 2019
Hi
how to write a proggram to round numbers whitout a prepared command in matlab like (round)
  2 comentarios
farid khalafi
farid khalafi el 23 de En. de 2019
I want to write rounding program (in any way)
I want to know ... how round command works?

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 23 de En. de 2019
Editada: Jan el 23 de En. de 2019
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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by