The way to solve a singular matrix

조회 수: 30 (최근 30일)
Amad-Adeen Baiuk
Amad-Adeen Baiuk 2014년 8월 22일
댓글: Aditya Agrawal 2020년 12월 8일
Hi
There is any one know how the method to decompose the singular square matrix using Matlab. Someone told me the Matlab have something like a ready Forthran subroutine. Does anyone know how to use it in Matlab?

답변 (3개)

Mikhail
Mikhail 2014년 8월 22일
  댓글 수: 1
Amad-Adeen Baiuk
Amad-Adeen Baiuk 2014년 8월 23일
thanks Mikhail. but how can apply the svd to find the inverse of square singular matrix in order to solve the set of linear system.

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


John D'Errico
John D'Errico 2014년 8월 23일
편집: John D'Errico 2014년 8월 23일
help pinv
Not much more to say, since you give very little info to help you on. Note that computing the inverse of a matrix is almost never recommended. The backslash operator is a better choice always than inv. But pinv is a good tool for this purpose, when backslash (and surely also inv) will fail.
A = ones(2);
A\[1;1]
Warning: Matrix is singular to working precision.
ans =
NaN
NaN
inv(A)*[1;1]
Warning: Matrix is singular to working precision.
ans =
Inf
Inf
pinv(A)*[1;1]
ans =
0.5
0.5
  댓글 수: 2
Einat Shoval
Einat Shoval 2017년 12월 24일
Thank you so much for this!! Was stuck on this for two days now until I found your answer :)
Aditya Agrawal
Aditya Agrawal 2020년 12월 8일
Thankyou so much! I had the same issue and your solution works!

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


Jess
Jess 2016년 3월 22일
% Goal: solve A*x == b for x
% Set up some matrix A (I used a sparse matrix) -- do yourself
% Set up the vector b -- do yourself
% Perform SVD on A
[U,S,V] = svd(A);
% A == U*S*V' % Not needed, but you can check it yourself to confirm
% Calc number of singular values
s = diag(S); % vector of singular values
tolerance = max(size(A))*eps(max(s));
p = sum(s>tolerance);
% Define spaces
Up = U(:,1:p);
%U0 = U(:,p+1:Nx);
Vp = V(:,1:p);
%V0 = V(:,p+1:Nx);
%Sp = spdiags( s(1:p), 0, p, p );
SpInv = spdiags( 1.0./s(1:p), 0, p, p );
% Calc AInv such that x = AInv * b
AInv = Vp * SpInv * Up';
x = AInv * b; % DONE!
  댓글 수: 1
Xin Shen
Xin Shen 2019년 7월 10일
When I tried your idea to solve my problem, I got an error "SVD does not support sparse matrices. Use SVDS to compute a subset of the singular values and vectors of a sparse matrix". Does SVDS work for your idea?

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by