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

21 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by