Skip to content

Instantly share code, notes, and snippets.

@theptrk
Created April 20, 2020 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theptrk/d886cbff40da76a0d8514a18077b23ab to your computer and use it in GitHub Desktop.
Save theptrk/d886cbff40da76a0d8514a18077b23ab to your computer and use it in GitHub Desktop.
function X_rec = recoverData(Z, U, K)
% initialize recovered values
X_rec = zeros(size(Z, 1), size(U, 1));
for i = 1:size(X_rec,1)
% projected_x is (1, K)
projected_x = Z(i, :);
% initialize x
x = zeros(1, size(U,1));
% iterate through dimensions to recover value
for j = 1:size(x, 2)
% Ufor_dimension = (1, K)
Ufor_dimension = U(j, 1:K);
% set the value for this dimension
% (1, K) * (1, K)'
% (1, K) * (K, 1) = (1, 1)
recovered_for_dimension = projected_x * Ufor_dimension';
x(j) = recovered_for_dimension;
end
X_rec(i,:) = x;
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment