MATLAB float accuracy

时光毁灭记忆、已成空白 提交于 2019-12-11 07:09:07

问题


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

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

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?


回答1:


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

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

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


来源:https://stackoverflow.com/questions/26358785/matlab-float-accuracy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!