What does the following MATLAB code do?

 Respuesta aceptada

Star Strider
Star Strider el 4 de Mzo. de 2018
It takes ‘x’, raises it to the ‘n’-th power, adds ‘delta’ to it, then rounds that result toward zero, divides that result by ‘10^n’ and prints the result.
The intent appears to be to round ‘x’ to 7 decimal places.
You can do that easily with the current version of the round function:
r = round(x, 7)
that will produce the same result.

1 comentario

I noticed that it does not do the same thing as round(x,n) for negative numbers.
>> fix(-pi*100000+0.5)/100000
ans =
-3.14158
>> round(-pi,5)
ans =
-3.14159

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.

Preguntada:

el 4 de Mzo. de 2018

Comentada:

el 4 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by