杨氏双缝干涉matlab代码
时间: 2023-11-25 19:32:36 浏览: 55
以下是杨氏双缝干涉matlab代码:
clc;
clear all;
close all;
%定义常量
wavelength=0.0000006328;%波长
distance=0.02;%两缝距离
slit_width=0.00025;%缝宽
screen_distance=0.3;%屏幕距离
screen_width=0.1;%屏幕宽度
x=linspace(-screen_width/2,screen_width/2,5000);%取样点
%计算光程差
d1=sqrt(distance^2+(x-slit_width/2).^2);
d2=sqrt(distance^2+(x+slit_width/2).^2);
delta=d2-d1;
%计算干涉条纹强度
intensity=(cos(pi*delta/wavelength)).^2;
%绘制图像
plot(x,intensity);
xlabel('Position on screen (m)');
ylabel('Relative intensity');
title('Young''s Double Slit Interference Pattern');
grid on;
%显示结果
fprintf('The distance between the two slits is %0.2f mm.\n',distance*1000);
fprintf('The width of each slit is %0.2f um.\n',slit_width*1000000);
fprintf('The wavelength of the light is %0.2f nm.\n',wavelength*1000000000);
fprintf('The distance between the slits and the screen is %0.2f m.\n',screen_distance);
fprintf('The width of the screen is %0.2f m.\n',screen_width);
fprintf('The maximum intensity is %0.2f.\n',max(intensity));
阅读全文