How to get the cofactor matrix of any given square matrix (singular or non singular)?
조회 수: 38 (최근 30일)
이전 댓글 표시
Even if the order of matrix is 3x3,4x4 or higher and especially when determinant=0 and we can't use inv().
댓글 수: 0
채택된 답변
John D'Errico
2022년 8월 24일
편집: John D'Errico
2022년 8월 24일
The matrix of cofactors is moderately well posed, even when the matrix is itself singular. Of course, what you would do with it is your choice. But the simple answer is to just use loops, since each element of the matrix of cofactors is itself just a lower order determaint. But why, when we already have adjoint? For example, the 4x4 magic square produced by magic:
A = magic(4)
rank(A)
While it is a magic square, the matrix is itself singular. So we coiuld not use the determinant of the matrix itself. However, you can just use the adjoint function.
help adjoint
format short g
adjoint(A)
If A were in fact non-singular, for example:
B = hilb(3)
rank(B)
adjoint(B)
We can see that for the non-singular matrix B, the adjoint divided by the determinant does produce an "inverse".
inv(B) - adjoint(B)/det(B)
Would you want to use this to compute the inverse? Of course not. You never want to use the determinant to do virtually anything.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!