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

21 vues (au cours des 30 derniers jours)
Kumaresh Kumaresh
Kumaresh Kumaresh le 10 Mai 2023
Réponse apportée : Manish le 23 Août 2024
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

Réponses (1)

Manish
Manish le 23 Août 2024
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!

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by