From beb652a5be449712d6922c683b0aa0a39426b701 Mon Sep 17 00:00:00 2001 From: neingeist Date: Wed, 19 Nov 2014 21:22:28 +0100 Subject: [PATCH] Recover data --- ex7/recoverData.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ex7/recoverData.m b/ex7/recoverData.m index da277f5..21e3b18 100644 --- a/ex7/recoverData.m +++ b/ex7/recoverData.m @@ -1,7 +1,7 @@ function X_rec = recoverData(Z, U, K) -%RECOVERDATA Recovers an approximation of the original data when using the +%RECOVERDATA Recovers an approximation of the original data when using the %projected data -% X_rec = RECOVERDATA(Z, U, K) recovers an approximation the +% X_rec = RECOVERDATA(Z, U, K) recovers an approximation the % original data that has been reduced to K dimensions. It returns the % approximate reconstruction in X_rec. % @@ -19,9 +19,17 @@ X_rec = zeros(size(Z, 1), size(U, 1)); % recovered_j = v' * U(j, 1:K)'; % % Notice that U(j, 1:K) is a row vector. -% +% + +U_reduce = U(:, 1:K); +for i = 1:size(Z, 1) + z = Z(i, :)'; + x_rec = z' * U_reduce'; + + X_rec(i, :) = x_rec; +end % =============================================================