function [cont,slitsep] = Youngslits1D(field1,pxs)
% plot visibility vs pinhole separation
% function [visibility,dx] = Youngslits1D(field1,pxs)
% inputs: field1 - complex field at input plane
%         pxs - pixel size [m]
% outputs:visibility - visibility vs. slit separation
%         dx - slit separation
%
% Laura Waller, 2011 Princeton University, lwaller@alum.mit.edu
%field1=incohbeamIN;
[n,nm]=size(field1);
% ceil(A): round the elements of A to their nearest integers 
% (greater than or equal to the elements). 
for ss=1:10:50 % length(1:ceil(n/4))    %pinhole separation distance in pixels
    mask=zeros(n,1);
    mask(ceil(n/2))=1;
    mask(ceil(n/2)+ss)=1;
    sd = ss*pxs*10^6;
    for nn=1:nm
        kcoh(:,nn)=fftshift(fft(mask.*field1(:,nn)));
    end
    cInt=mean(abs(kcoh.^2),2);
    figure;plot(cInt);v=axis;v(3)=0;v(4)=3;axis(v);
    legend(['Slit Separation =' num2str(sd)  ' um'], 'Location','north') ;
    legend boxoff  
    drawnow; pause(0.1)
    cont(ss)=(max(cInt)-min(cInt))/(max(cInt)+min(cInt));
    slitsep(ss)=ss*pxs*10^6;
end