How to eliminate the following warning: matrix singular to machine precision

20 ビュー (過去 30 日間)
Kumaresh Kumaresh
Kumaresh Kumaresh 2023 年 5 月 10 日
回答済み: Manish 2024 年 8 月 23 日
Hello all, 
In the following equation, Az = b;
z = A\b;
When I solve for z by the inverse of A, I get this message:
warning: matrix singular to machine precision
My [A] matrix is actually non-singular. But the warning message seems to be explaining that the [A] matrix is singular (its determinant is 0) somewhere in my big matrix, and thus it does not have an inverse.
Can this be avoided? And will such a warning influence the results significantly?
Thank you

回答 (1 件)

Manish
Manish 2024 年 8 月 23 日
Hi,
I understand that you are using the "mldivide(\)" function on your matrices and are encountering a warning. You are seeking a way to bypass this warning.
The warning "Matrix is singular to working precision" is generated when the condition number of a matrix is zero. This condition number is independent of the matrix's singularity. The condition number is determined using the "rcond" function.
Refer to the Linear System with Singular Matrix section of the document.
There may be instances where a matrix is non-singular, yet the "rcond" value can still be zero.
%Example
A = [1, 1; 1, 1 + 1e-16];
determinant = det(A);
if determinant == 0
disp('The matrix is singular.');
else
disp('The matrix is non-singular.');
end
rcond_value = rcond(A);
disp(rcond_value)
Refer to the “rcond” documentation in the below link:
To bypass this warning, you can try the following:
1) Regularization: Techniques such as Tikhonov regularization add a small value to the diagonal elements of the matrix, effectively improving its condition number.
2) Rescaling: Adjusting the scales of the matrix's columns or rows can sometimes improve conditioning.
Hope it helps!

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by