projectData.m 920 B

1234567891011121314151617181920212223242526
  1. function Z = projectData(X, U, K)
  2. %PROJECTDATA Computes the reduced data representation when projecting only
  3. %on to the top k eigenvectors
  4. % Z = projectData(X, U, K) computes the projection of
  5. % the normalized inputs X into the reduced dimensional space spanned by
  6. % the first K columns of U. It returns the projected examples in Z.
  7. %
  8. % You need to return the following variables correctly.
  9. Z = X * U(:,1:K);
  10. % ====================== YOUR CODE HERE ======================
  11. % Instructions: Compute the projection of the data using only the top K
  12. % eigenvectors in U (first K columns).
  13. % For the i-th example X(i,:), the projection on to the k-th
  14. % eigenvector is given as follows:
  15. % x = X(i, :)';
  16. % projection_k = x' * U(:, k);
  17. %
  18. % =============================================================
  19. end