recoverData.m 968 B

1234567891011121314151617181920212223242526272829
  1. function X_rec = recoverData(Z, U, K)
  2. %RECOVERDATA Recovers an approximation of the original data when using the
  3. %projected data
  4. % X_rec = RECOVERDATA(Z, U, K) recovers an approximation the
  5. % original data that has been reduced to K dimensions. It returns the
  6. % approximate reconstruction in X_rec.
  7. %
  8. % You need to return the following variables correctly.
  9. X_rec = Z * U(:,1:K)';
  10. % ====================== YOUR CODE HERE ======================
  11. % Instructions: Compute the approximation of the data by projecting back
  12. % onto the original space using the top K eigenvectors in U.
  13. %
  14. % For the i-th example Z(i,:), the (approximate)
  15. % recovered data for dimension j is given as follows:
  16. % v = Z(i, :)';
  17. % recovered_j = v' * U(j, 1:K)';
  18. %
  19. % Notice that U(j, 1:K) is a row vector.
  20. %
  21. % =============================================================
  22. end