function [R]=mig(D,nx,nz,nt,dx,dz,dt,c,sx,W,nd2,TGX)
% 
% Compute diffraction stack response D(gx,t) of 
% source at sx & reflectivity distribution given by R
%
cnst=1/c/dt;R=zeros(nx,nz);         %Define Constants

for gx=1:nx;gx                      %Loop Over Traces
  for t=1:nt;                       %Loop over time sample/trace
   R=W(t-TGX(:,:,gx)-TGX(:,:,sx)+nd2)*D(gx,t)+R;
  end;
end;
imagesc([1:nx]*dx,[1:nz]*dz,R);xlabel('X (m)');ylabel('Depth (m)');
title('Point Scatterer Resonse of Migration Operator');
hold on;plot(sx*dx,dx,'*w');hold off

