Skip to content

ex7/PCA -> projectData.m and recoverData.m vectorized #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

egoistpizza
Copy link

Updated two of the graded assignments in the PCA section of the ex7 exercise, projectData.m and recoverData.m.
The for-loops used to assign the Z and X_rec variables have been converted to non-iterative vectorized matrix multiplication single-line codes.

Before -> After (projectData.m)

% Before

for i = 1: size(X, 1)
  Z(i, :) = (U_reduce'*X(i, :)')';
end

% After

Z = (U_reduce' * X')';

Before -> After (recoverData.m)

% Before

for i = 1:size(Z, 1)
  X_rec(i, :) = (U_reduce*Z(i, :)')';
end

% After

X_rec = (U_reduce*Z')';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant