1 简介
波动光学是电磁波动理论基础上研究光波动现象的一门学科,包括干涉实验和衍射实验两大类,光学实验对实验要求非常严苛,故而多采用计算机仿真光学实验。本文主要对基于MATLAB的波动光学实验中干涉原理进行分析,讨论几种干涉实验仿真的实现。
2 部分代码
%slider和edit使用
selection=get(handles.uipanel1,'selectedobject');
NCLevels=255;
switch get(selection,'tag')
case 'Newton'
R=get(handles.edit2,'value');
axes(handles.axes1);
Lambda=get(handles.uipanel1,'userdata').*1e-4;
x=-4:8/250:4;y=x;
[X,Y]=meshgrid(x);
r=sqrt(X.^2+Y.^2);
I=cos(pi*(r.^2/R+Lambda/2)/Lambda).^2;
colormap(gray(NCLevels));
Ir=I*NCLevels;
image(x,y,Ir);
title('牛顿环(单位:mm)');
axis square;
axes(handles.axes2);
plot(r(126,:),I(126,:),'k')
title('干涉光强分布图');
xlabel('r/mm(环半径)');
ylabel('相对光强');
set(gca,'XLim',[0 3]);
case'interferometry1'
interferometry1_handle=findobj('tag','interferometry1');
a=get(interferometry1_handle,'userdata');
if isempty(a)
h=msgbox('未输入缝间距','输入错误','warn');
else
Lambda=get(handles.uipanel1,'userdata').*1e-4;D=1000;%D为缝到屏的距离,a为缝宽,Lambda是波长
ym=1;xs=ym;
n=501;ys=linspace(-ym,ym,n);
r1=sqrt((ys-a/2).^2+D^2);
r2=sqrt((ys+a/2).^2+D^2);
phi=2*pi*(r2-r1)./Lambda;
B=4*cos(phi/2).^2;
Br=B/max(B)*NCLevels;
axes(handles.axes1);
image(xs,ys,Br');
title('干涉条纹');
colormap(gray(NCLevels));
axes(handles.axes2);
plot(B,ys)
title('干涉光强分布图');
xlabel('相对光强');
end
case'Michelson'
Michelson_handle=findobj('tag','Michelson');
d=get(Michelson_handle,'userdata');
if isempty(d)
h=msgbox('未输入空气薄膜厚度','输入错误','warn');
else
Lambad=get(handles.uipanel1,'userdata').*1e-4;f=200;
xm=15;
N=200;
x=linspace(-xm,xm,N);y=x;
[X,Y]=meshgrid(x);
r=sqrt(X.^2+Y.^2);
I=cos(2*pi*d*cos(atan(r/f))/Lambad).^ 2;
I1=I*NCLevels;
axes(handles.axes1);
image(x,y,I1);
title('干涉条纹');
colormap(gray(NCLevels));
axis square;axis off;
axes(handles.axes2);
plot(r(101,:),I(101,:),'k')
title('干涉光强分布图');
xlabel('r/mm(环半径)');
ylabel('相对光强');
set(gca,'XLim',[0 15]);
end
case 'radiobutton9'
radiobutton9_handle=findobj('tag','radiobutton9');
N=get(radiobutton9_handle,'userdata');
if isempty(N)
h=msgbox('未输入光束条数','输入错误','warn');
else
Lambda=get(handles.uipanel1,'userdata').*1e-4;
d=2;f=1000;%f为缝后透镜焦距,a为缝宽,d为光栅常量,Lambda是波长
y=linspace(-1,1,500);
theta=asin(y./sqrt(y.^2+f^2));
gramma=pi*d*sin(theta)/Lambda;
I=(sin(N*gramma)./sin(gramma)).^2;
I1=I/max(I);I2=I1'*NCLevels;
axes(handles.axes1);
image(I2);
colormap(gray(NCLevels));
title('衍射图像')
axis off;
axes(handles.axes2);
plot(I1,y)
title('光强分布图');
xlabel('相对光强');
end;
case'sslit'
sslit_handle=findobj('tag','sslit');
a=get(sslit_handle,'userdata');
if isempty(a)
h=msgbox('未输入狭缝宽度','输入错误','warn');
else
Lambda=get(handles.uipanel1,'userdata').*1e-4;z=1000;
ym=10;xs=ym;
ny=101;
ys=linspace(-ym,ym,ny);
theta=asin(ys./sqrt(ys.^2+z.^2));
u=pi*a*sin(theta)/Lambda;
b=sinc(u/pi).^2;
br=(b/max(b))*NCLevels;
axes(handles.axes1);
image(xs,ys,br*2.5);
axis off;
title('衍射条纹');
colormap(gray(NCLevels));
axes(handles.axes2);
plot(b/max(b),ys);
title('光强分布图');
xlabel('相对光强');
end
case'circular'
circular_handle=findobj('tag','circular');
a=get(circular_handle,'userdata');
f=600;Lambda=get(handles.uipanel1,'userdata').*1e-4;
x=linspace(-10,10,100);y=x;
[X,Y]=meshgrid(x,y);
r=sqrt(X.^2+Y.^2);
theta=atan(sqrt(X.^2+Y.^2)/f);
alpha=pi*a*sin(theta)/Lambda;
I=(besselj(1,2*alpha)./alpha).^2;%一阶贝塞尔函数
Ir=NCLevels*I;
colormap(gray(NCLevels));
axes(handles.axes1);
image(x,y,Ir*20);
title('衍射图像');
axis square;
axis off;
axes(handles.axes2);
plot(r(51,:),I(51,:))
title('光强分布截面图');
xlabel('半径r');
ylabel('相对光强');
set(gca,'XLim',[0 10]);
case'mslit'
mslit_handle=findobj('tag','mslit');
N=get(mslit_handle,'userdata');
if isempty(N)
h=msgbox('未输入缝数','输入错误','warn');
else
Lambda=get(handles.uipanel1,'userdata').*1e-4;a=0.005;d=get(handles.edit5,'value')*a;f=64;%f为缝后透镜焦距,a为缝宽,d为光栅常量,Lambda是波长
y=linspace(-20,20,500);
theta=asin(y./sqrt(y.^2+f^2));
beta=pi*a*sin(theta)/Lambda;
gramma=pi*d*sin(theta)/Lambda;
I=(sinc(beta/pi)).^2.*(sin(N*gramma)./sin(gramma)).^2;
I1=I/max(I);I2=I1'*NCLevels;
axes(handles.axes1);
image(I2*2);
colormap(gray(NCLevels));
title('衍射图像')
axis off;
axes(handles.axes2);
plot(I1,y)
title('光强分布图');
xlabel('相对光强');
end;
end;
3 仿真结果
4 参考文献
[1]赵鑫. MATLAB在波动光学教学中的应用[J]. 通讯世界:下半月, 2016(2):2.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。