Regarding understanding of the following SVD code in matlab

1.6k Views Asked by At

I earlier had a doubt regarding pseudo-inverse of a matrix, and earlier I was using pinv function. But one of the answers gave an alternative technique that is singular value decomposition method. I have a very little understanding of the method... can anyone please suggest some literature for understanding it properly so that I can understand the following code completely...or can explain the code in simple words..

please help..

R=[2,1,5;-2,-1,-5];
% pseudo inverse of A
[m,n]   = size(R);
% get SVD
[U,S,V] = svd(R);
% check rank
r       = rank(S);
SR      = S(1:r,1:r);
% make complete if rank is not full
SRc     = [SR^-1 zeros(r,m-r);zeros(n-r,r) zeros(n-r,m-r)];
% create inverse
A_inv   = V*SRc*U.';

g1 = zeros(size(k31));
g2 = zeros(size(k31));
g3 = zeros(size(k31));
1

There are 1 best solutions below

0
On

Wikipedia is your friend: Applications of the SVD. Look at the pseudo-inverse and rank sections.