From: Michael Orlitzky Date: Sun, 5 May 2013 02:52:06 +0000 (-0400) Subject: Check for error flag in rank_k_approximation(). X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=commitdiff_plain;h=9c80bead819622e76966fe80b75bf422bc78cdcc;ds=sidebyside Check for error flag in rank_k_approximation(). --- diff --git a/rank_k_approximation.m b/rank_k_approximation.m index 9883084..4443259 100644 --- a/rank_k_approximation.m +++ b/rank_k_approximation.m @@ -23,6 +23,11 @@ function Ak = rank_k_approximation(A,k) return; end - [U, S, V] = svds(A, k); - Ak = U*S*V'; + [U, S, V, flag] = svds(A, k); + + if (flag == 0) + Ak = U*S*V'; + else + error('Could not compute the rank-k approximation.'); + end end