Skip to content

Instantly share code, notes, and snippets.

@grondilu
Created February 20, 2014 10:51
Show Gist options
  • Save grondilu/9111102 to your computer and use it in GitHub Desktop.
Save grondilu/9111102 to your computer and use it in GitHub Desktop.
random-number-based holography
function H = hologram(V, m)
H = zeros(m, 1);
for index=1:length(V)
disp(index);
rand("seed", index);
R = rand(m, 1);
H += V(index)*exp(2*pi*R*i);
end
end
function y = reconstruct(H, index)
m = length(H);
rand("seed", index);
R = rand(m, 1);
y = exp(2*pi*R*i)' * H;
end
n = 100;
y = cumsum(rand(n, 1)-.5);
m = 1000;
H = hologram(y, m);
Y = [];
for index=1:n
disp(n-index);
Y = [Y; reconstruct(H, index)];
end
Y = real(Y) / m;
plot(1:n, y, 1:n, Y);
pause;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment