1 function Ak = rank_k_approximation(A,k)
3 % Compute the rank-k approximation to A from the ``k`` largest
4 % singular values of A.
8 % - ``A`` -- The matrix to approximate.
10 % - ``k`` -- The rank of the resulting matrix; i.e. the number
11 % of (large) singular values to keep.
15 % - ``Ak`` -- The rank-k approximation to ``A``.
17 [U, S, V] = svds(A, k);