What does the following MATLAB code do?

 采纳的回答

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 个评论

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

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Operators and Elementary Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by