% AO Phase Reconstruction Problem in 1D % Computational grid. n = 200; h = 1/(n+1); x = [h:h:1-h]; % First and second derivative matrices e = ones(n,1); A = (1/h^2)*spdiags([e, -2*e, e],[-1 0 1], n,n); A = full(A); D = (1/h)*spdiags([-e e], [0 1], n,n); D = full(D); % Generate true phase using biharmonic approximation of the Kolmogorov % covariance matrix. xx = 100*randn(n,1); phase = A\xx; sig = 0.1; data = D*phase + sig*rand(n,1); SNR = norm(data)/sqrt(n*sig^2) % Compute phase reconstruction recon = A\(D*data); % Plote results figure(1) plot(x,data) title('Derivative Data Plot') figure(2) plot(x,phase) hold on plot(x,recon,'r--') hold off title('True phase (-) and reconstructed phase (--)')