Path: blob/master/Week 8/Programming Assignment - 7/ex7/projectData.m
863 views
function Z = projectData(X, U, K)1%PROJECTDATA Computes the reduced data representation when projecting only2%on to the top k eigenvectors3% Z = projectData(X, U, K) computes the projection of4% the normalized inputs X into the reduced dimensional space spanned by5% the first K columns of U. It returns the projected examples in Z.6%78% You need to return the following variables correctly.9Z = zeros(size(X, 1), K);1011% ====================== YOUR CODE HERE ======================12% Instructions: Compute the projection of the data using only the top K13% eigenvectors in U (first K columns).14% For the i-th example X(i,:), the projection on to the k-th15% eigenvector is given as follows:16% x = X(i, :)';17% projection_k = x' * U(:, k);18%19U_reduce = U(:,[1:K]);20Z = X * U_reduce;21% =============================================================2223end242526