本文采用gui演示杨氏双缝干涉实验,可以调整参数,实验原理详参光学教程。
%读入实验参数
lambda=str2num(get(handles.edit1,'string'))*1e-9; %读入波长
d=str2num(get(handles.edit2,'string'))*1e-3; %读入孔距
D=str2num(get(handles.edit3,'string')); %读入观察屏距离
%读入观察范围参数
xa=str2num(get(handles.edit4,'string')); %最小的横坐标值
xb=str2num(get(handles.edit5,'string')); %最大的横坐标值
n1=str2num(get(handles.edit6,'string')); %x方向等分份数
ya=str2num(get(handles.edit7,'string')); %最小的纵坐标值
yb=str2num(get(handles.edit8,'string')); %最大的纵坐标值
n2=str2num(get(handles.edit9,'string')); %y方向等分份数
k=2*pi/lambda; %计算波数
x=linspace(xa,xb,n1); %x坐标
y=linspace(ya,yb,n2); %y坐标
[x,y]=meshgrid(x,y);
r1=sqrt((x-d/2).^2+y.^2+D^2);
r2=sqrt((x+d/2).^2+y.^2+D^2);
I=(cos(k*r1)./r1+cos(k*r2)./r2).^2+(sin(k*r1)./r1+sin(k*r2)./r2).^2;
I=I/(max(max(I)));
I=I*255;
axes(handles.axes1)
x=linspace(xa,xb,n1);
y=linspace(ya,yb,n2);
image(x,y,I)
colormap(gray(255))
xlabel('x (m)')
ylabel('y (m)')
title('杨氏双孔干涉条纹')
%读入实验参数
lambda=str2num(get(handles.edit1,'string'))*1e-9; %读入波长
d=str2num(get(handles.edit2,'string'))*1e-3; %读入孔距
D=str2num(get(handles.edit3,'string')); %读入观察屏距离
%读入观察范围参数
xa=str2num(get(handles.edit4,'string')); %最小的横坐标值
xb=str2num(get(handles.edit5,'string')); %最大的横坐标值
n1=str2num(get(handles.edit6,'string')); %x方向等分份数
ya=str2num(get(handles.edit7,'string')); %最小的纵坐标值
yb=str2num(get(handles.edit8,'string')); %最大的纵坐标值
n2=str2num(get(handles.edit9,'string')); %y方向等分份数
k=2*pi/lambda; %计算波数
x=linspace(xa,xb,n1); %x坐标
y=linspace(ya,yb,n2); %y坐标
[x,y]=meshgrid(x,y);
r1=sqrt((x-d/2).^2+y.^2+D^2);
r2=sqrt((x+d/2).^2+y.^2+D^2);
I=(cos(k*r1)./r1+cos(k*r2)./r2).^2+(sin(k*r1)./r1+sin(k*r2)./r2).^2;
I=I/(max(max(I)));
axes(handles.axes1)
x=linspace(xa,xb,n1);
y=linspace(ya,yb,n2);
mesh(x,y,I)
colormap(hot)
xlabel('x (m)')
ylabel('y (m)')
zlabel('光强')
title('光强分布')
完整代码请加小编 qq1575304183
来源:CSDN
作者:天天matlab
链接:https://blog.csdn.net/qq_34763204/article/details/104180175