How can I get inverse matrix at 50 x 50 sparse matrix?

조회 수: 4 (최근 30일)
Esther Kang
Esther Kang 2024년 10월 18일
댓글: Bruno Luong 2024년 10월 18일
Hello,
I have a square sparse matrix A (50 x 50), and I need to get the inverse matrix of A.
for example, at A x B = C, I know A and C so I have to know matrix B. So I have to get A's inverse matrix.
But if I use inv(A) at the code, every matrix element of inv(A) get 'inf'.
How could I get this inverse matrix? Do I have other method to get matrix B?
  댓글 수: 1
Bruno Luong
Bruno Luong 2024년 10월 18일
Typically this happens when you try to solve on non invertible matrix. Small example
A=[1 2; 1 2]
A = 2×2
1 2 1 2
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
inv(A)
Warning: Matrix is singular to working precision.
ans = 2×2
Inf Inf Inf Inf
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
B=rand(2);
C=A*B
C = 2×2
1.5628 0.6109 1.5628 0.6109
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
B = A\C
Warning: Matrix is singular to working precision.
B = 2×2
NaN NaN NaN NaN
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2024년 10월 18일
If inv(A) is all inf then chances are that A is singular. You should check rank(A) before proceeding.
You should probably not be forming inv(A) explicitly. You should probably be using
B = A\C;
The \ operator will find a solution that minimizes the sum of squares
Note that the inverse of a sparse matrix is typically a dense matrix. But that isn't going to matter if you use the \ operator.
  댓글 수: 3
Angelo Yeo
Angelo Yeo 2024년 10월 18일
@Esther Kang, can you give us a sample data to reproduce the issue?
Esther Kang
Esther Kang 2024년 10월 18일
Thank you for your reply @Angelo Yeo, I solved this problem by initial condition just before!
I had to calculate power flow using newton Raphson, and I set initial votage to 0. So I couldn't get the inverse of matrix A.(actually it was Jacobian matrix in power flow) I set initial voltage to 1, and now it works!!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Newton-Raphson Method에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by