Matrix inverse with svd

조회 수: 31 (최근 30일)
Elie Hatem
Elie Hatem 2021년 6월 7일
댓글: Arnab Paul 2023년 10월 27일
Hello,
I am trying to invert a matrix using svd and \ and comparing the result with inv().
For this matrix:
A = [ 2 4 6; 8 5 7 ; 0 3 1]
I did the svd decomposition as follows:
[U,S,V] = svd(A);
And, I believe the inverse of A can be expressed as :
So, I tried it by writing the code below:
disp('inverse with svd:')
disp(V*S\U')
And, I got this answer:
inverse with svd:
0.0236 0.0440 -0.0528
0.1765 0.1361 0.1922
0.4277 -0.3787 -0.1247
Then, I tried to invert A using inv() as follows:
disp('inverse with inv:')
disp(inv(A))
However, I got a different answer as seen below:
inverse with inv:
-0.2000 0.1750 -0.0250
-0.1000 0.0250 0.4250
0.3000 -0.0750 -0.2750
Can someone tell me what I am doing wrong?
My main goal is that I want to use svd to invert large matrices that may be close to becoming singular.
Thank you

채택된 답변

Christine Tobler
Christine Tobler 2021년 6월 7일
Use one of
A = [ 2 4 6; 8 5 7 ; 0 3 1]
A = 3×3
2 4 6 8 5 7 0 3 1
[U,S,V] = svd(A);
V*inv(S)*U'
ans = 3×3
-0.2000 0.1750 -0.0250 -0.1000 0.0250 0.4250 0.3000 -0.0750 -0.2750
V*(S\U')
ans = 3×3
-0.2000 0.1750 -0.0250 -0.1000 0.0250 0.4250 0.3000 -0.0750 -0.2750
% The formula you're using above puts the parentheses in a different place
% than you think:
V*S \ U'
ans = 3×3
0.0236 0.0440 -0.0528 0.1765 0.1361 0.1922 0.4277 -0.3787 -0.1247
(V*S) \ U'
ans = 3×3
0.0236 0.0440 -0.0528 0.1765 0.1361 0.1922 0.4277 -0.3787 -0.1247
  댓글 수: 2
Elie Hatem
Elie Hatem 2021년 6월 7일
Thank you so much!
Arnab Paul
Arnab Paul 2023년 10월 27일
What happens to non-square matrix?
is it same as pinv(A)?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by