xs=linspace(-xm,xm,n); %用线性采样法生成两个一位数组 xs,ys
%(n 为总点数)
ys=linspace(-ym,ym,n);
L1=sqrt((xs-d/2).^2+ys.^2+D^2);%光屏上点(xs,ys)距光源 1 距离 r1
L2=sqrt((xs+d/2).^2+ys.^2+D^2);%光屏上点(xs,ys)距光源 2 距离 r2
E1=A1./sqrt(L1).*exp(1i*L1*2*pi/lam);%光源 1 在接受屏上复振幅 E1
E2=A2./sqrt(L2).*exp(1i*L2*2*pi/lam);%光源 2 在接受屏上复振幅 E2
E=E1+E2; %复振幅叠加为合成振幅 E
I=abs(E).^2; %和振幅光强
nc=255; %灰度
br=(I/4)*nc; %灰度强度
image(xs,ys,br); %生成干涉图样
colormap(gray(nc));
③初始干涉仿真图样
④改变参数后的仿真图样(缝宽即光振幅 A1、A2,缝间距 d)