MATLAB浮点精度 [英] MATLAB float accuracy

查看:144
本文介绍了MATLAB浮点精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查QR算法的数值稳定性,为此,我需要创建如下矩阵:

I want to check numerical stability of QR algorithm, for this i need to create matrix like this:

 S = diag(2.^(-1:-1:-80));

但是它的排名是46,我认为是因为缺乏准确性.但是在我正在读的书中,它是完整排名的矩阵.如何提高计算的准确性?

But it has rank 46, i think it is because of lack of accuracy. But in the book i'm reading it is full ranked matrix. How can i increase accuracy of computations?

推荐答案

您可以使用 vpa (可变精度算术):

You can use vpa (variable precision ariuthmetic):

>> S = diag(2.^vpa((-1:-1:-80)), 100); %// 100 here is number of precision digits
>> rank(S)
ans =
    80

请注意,结果的类型为sym.如有必要,转换为double:

Note that the result is of type sym. Convert to double if needed:

>> double(rank(S))
ans =
    80

这篇关于MATLAB浮点精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆