forked from sgang007/gaitoraid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
projectData.m
28 lines (21 loc) · 928 Bytes
/
projectData.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function Z = projectData(X, U, K)
%PROJECTDATA Computes the reduced data representation when projecting only
%on to the top k eigenvectors
% Z = projectData(X, U, K) computes the projection of
% the normalized inputs X into the reduced dimensional space spanned by
% the first K columns of U. It returns the projected examples in Z.
%
% You need to return the following variables correctly.
Z = zeros(size(X, 1), K);
% ====================== YOUR CODE HERE ======================
% Instructions: Compute the projection of the data using only the top K
% eigenvectors in U (first K columns).
% For the i-th example X(i,:), the projection on to the k-th
% eigenvector is given as follows:
U_reduce = U(:,1:K);
for i=1:length(Z),
Z(i,:) = X(i,:) * U_reduce;
end
%
% =============================================================
end