作业帮 > 综合 > 作业

在matlab计算过程中保留小数点后5位,是什么意思?咋么实现?

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/10 23:36:01
在matlab计算过程中保留小数点后5位,是什么意思?咋么实现?
在matlab计算过程中保留小数点后5位,是什么意思?是每次计算的结果显示出小数点后5位?还是每次迭代都保留到前5位再进行迭代?
如何实现呢?默认是4位呀
比如你的结果是n,
n = roundn(n,-5);
这样结果就是5位小数了.
你直接在command window上输入n时看不到第五位的.
fprintf('%d',n);
看一下就可以看到了.
或者你可以在workspace里看到.
再问: 你说的不行呀 >> n=10.230409; >> roundn(n,-5) ans = 10.230409999999999
再答: 那个就是1,你在workspace里打开看一下。点进去看里面的值。 roundn Round to multiple of 10n Syntax roundn(x,n) Description roundn(x,n) rounds each element of x to the nearest multiple of 10n. n must be scalar, and integer-valued. For complex x, the imaginary and real parts are rounded independently. For n = 0, roundn gives the same result as round. That is, roundn(x,0) == round(x). Examples Round pi to the nearest hundredth. roundn(pi, -2) ans = 3.1400 这是matlab对于roundn的解释。