How to eliminate the following warning: matrix singular to machine precision
21 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
Manish
el 23 de Ag. de 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!
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!