Regularised Linear least squares via SVD in Matlab

96 Views Asked by At

enter image description here

Basically I'm trying to create a Matlab script where I can create the the Matrix S with diagonal entries as shown in equation 4 of the picture for different sizes n. However, I'm really struggling to do this. I can find the reduced SVD completely fine, it's just the creation of this 'S' matrix that I can't work out

1

There are 1 best solutions below

0
On

Given $\Sigma_1$, you can use the MATLAB's command $\texttt{diag()}$ to extract the diagonal elements of the matrix. After that, use element-wise operations to calculate the diagonal elements of $S$, and finally, use $\texttt{diag()}$ again to form the matrix $S$. It would look something like this:

[U1,Sigma,V] = svd(A,0);
d_Sigma = diag(Sigma);
d_S = d_Sigma./(d_Sigma.^2 + mu);
S = diag(d_S);