Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用具有不同数据精度的 6x6 矩阵。当我尝试在 MATLAB 中反转该矩阵时,我通常会得到Inf或NaN作为所有数据,并且 MATLAB 会引发警告:
Inf
NaN
矩阵对于工作精度来说是奇异的。
有没有办法避免它并获得正确的结果?
您的矩阵似乎排名不足。只有满秩矩阵才能被稳健地反转。 您可以通过在原始单位矩阵中添加一个小的单位矩阵来规避您的问题。
A = rand(6,5); A = A*A'; %' symmetric rank 5 matrix iA = inv(A); % results with NaNs and infs A is singular iAs = inv( A + eye(6)*1e-3 ); % add small (1e-3) elements to diagonal - this should help