1 简介

从光的电磁理论出发构建模型,运用MATLAB软件的矩阵计算能力,动态模拟了杨氏双缝干涉实验的全过程,并生成了一个便于实验教学演示的GUI用户界面.以日光为白光光源,把日光的可见光谱均匀分割为2 000份色光,利用Matlab软件实现了白光夫琅和费不同形状矩孔衍射实验的计算机仿真,并根据仿真结果分析了衍射图像的分布特征.结果表明,白光夫琅和费矩孔衍射的仿真图像,清晰,鲜艳而逼真,中央亮斑为白色,其余条纹则内紫外红;衍射的光强分布为两个相互垂直的单缝衍射因子相互调制的结果,单缝衍射是矩孔衍射的特例.​

2 部分代码

function varargout = untitled1(varargin)

% UNTITLED1 MATLAB code for untitled1.fig

%      UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing

%      singleton*.

%

%      H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to

%      the existing singleton*.

%

%      UNTITLED1('CALLBACK',hObject,eventData,handles,...) calls the local

%      function named CALLBACK in UNTITLED1.M with the given input arguments.

%

%      UNTITLED1('Property','Value',...) creates a new UNTITLED1 or raises the

%      existing singleton*.  Starting from the left, property value pairs are

%      applied to the GUI before untitled1_OpeningFcn gets called.  An

%      unrecognized property name or invalid value makes property application

%      stop.  All inputs are passed to untitled1_OpeningFcn via varargin.

%

%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one

%      instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help untitled1

% Last Modified by GUIDE v2.5 13-May-2019 12:05:52

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',       mfilename, ...

'gui_Singleton',  gui_Singleton, ...

'gui_OpeningFcn', @untitled1_OpeningFcn, ...

'gui_OutputFcn',  @untitled1_OutputFcn, ...

'gui_LayoutFcn',  [] , ...

'gui_Callback',   []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before untitled1 is made visible.

function untitled1_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% hObject    handle to figure

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% varargin   command line arguments to untitled1 (see VARARGIN)

% Choose default command line output for untitled1

handles.output = hObject;

axes(handles.axes1)

cData=imread('杨氏双缝实验.jpg');

image(cData);

title('杨氏双缝干涉示意图')

axis off;

set(handles.edit1,'String','建议范围200~1000nm');

set(handles.edit2,'String','建议范围0.1~0.5mm');

set(handles.edit3,'String','建议范围1~5m');

set(handles.edit4,'String','1');

set(handles.edit5,'String','1');

% Update handles structure

guidata(hObject, handles);

% --- Outputs from this function are returned to the command line.

function varargout = untitled1_OutputFcn(hObject, eventdata, handles)

% varargout  cell array for returning output args (see VARARGOUT);

% hObject    handle to figure

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure

varargout{1} = handles.output;

function edit1_Callback(hObject, eventdata, handles)

set(handles.slider1,'value',str2num(get(hObject,'string')));

% hObject    handle to edit1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text

%        str2double(get(hObject,'String')) returns contents of edit1 as a double

% --- Executes during object creation, after setting all properties.

function edit1_CreateFcn(hObject, eventdata, handles)

% hObject    handle to edit1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%       See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

% --- Executes on slider movement.

function slider1_Callback(hObject, eventdata, handles)

set(handles.edit1,'string',num2str(get(hObject,'value')));

% hObject    handle to slider1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

la=get(handles.slider1,'value');

set(handles.edit1,'string',num2str(la));

% Hints: get(hObject,'Value') returns position of slider

%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

% --- Executes during object creation, after setting all properties.

function slider1_CreateFcn(hObject, eventdata, handles)

% hObject    handle to slider1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.

if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor',[.9 .9 .9]);

end

function edit2_Callback(hObject, eventdata, handles)

set(handles.slider2,'value',str2num(get(hObject,'string')));

% hObject    handle to edit2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text

%        str2double(get(hObject,'String')) returns contents of edit2 as a double

% --- Executes during object creation, after setting all properties.

function edit2_CreateFcn(hObject, eventdata, handles)

% hObject    handle to edit2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%       See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

% --- Executes on slider movement.

function slider2_Callback(hObject, eventdata, handles)

set(handles.edit2,'string',num2str(get(hObject,'value')));

% hObject    handle to slider2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

d=get(handles.slider2,'value');

set(handles.edit2,'string',num2str(d));

% Hints: get(hObject,'Value') returns position of slider

%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

% --- Executes during object creation, after setting all properties.

function slider2_CreateFcn(hObject, eventdata, handles)

% hObject    handle to slider2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.

if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor',[.9 .9 .9]);

end

function edit3_Callback(hObject, eventdata, handles)

set(handles.slider3,'value',str2num(get(hObject,'string')));

% hObject    handle to edit3 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text

%        str2double(get(hObject,'String')) returns contents of edit3 as a double

% --- Executes during object creation, after setting all properties.

function edit3_CreateFcn(hObject, eventdata, handles)

% hObject    handle to edit3 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%       See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

% --- Executes on slider movement.

function slider3_Callback(hObject, eventdata, handles)

set(handles.edit3,'string',num2str(get(hObject,'value')));

% hObject    handle to slider3 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider

%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

D=get(handles.slider3,'value');

set(handles.edit3,'string',num2str(D));

% --- Executes during object creation, after setting all properties.

function slider3_CreateFcn(hObject, eventdata, handles)

% hObject    handle to slider3 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.

if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor',[.9 .9 .9]);

end

function edit4_Callback(hObject, eventdata, handles)

set(handles.slider4,'value',str2num(get(hObject,'string')));

% hObject    handle to edit4 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text

%        str2double(get(hObject,'String')) returns contents of edit4 as a double

% --- Executes during object creation, after setting all properties.

function edit4_CreateFcn(hObject, eventdata, handles)

% hObject    handle to edit4 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%       See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

% --- Executes on slider movement.

function slider4_Callback(hObject, eventdata, handles)

set(handles.edit4,'string',num2str(get(hObject,'value')));

% hObject    handle to slider4 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

A1=get(handles.slider1,'value');

set(handles.edit1,'string',num2str(A1));

% Hints: get(hObject,'Value') returns position of slider

%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

% --- Executes during object creation, after setting all properties.

function slider4_CreateFcn(hObject, eventdata, handles)

% hObject    handle to slider4 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.

if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor',[.9 .9 .9]);

end

function edit5_Callback(hObject, eventdata, handles)

set(handles.slider5,'value',str2num(get(hObject,'string')));

% hObject    handle to edit5 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text

%        str2double(get(hObject,'String')) returns contents of edit5 as a double

% --- Executes during object creation, after setting all properties.

function edit5_CreateFcn(hObject, eventdata, handles)

% hObject    handle to edit5 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%       See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

% --- Executes on slider movement.

function slider5_Callback(hObject, eventdata, handles)

set(handles.edit5,'string',num2str(get(hObject,'value')));

% hObject    handle to slider5 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

A2=get(handles.slider1,'value');

set(handles.edit1,'string',num2str(A2));

% Hints: get(hObject,'Value') returns position of slider

%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

% --- Executes during object creation, after setting all properties.

function slider5_CreateFcn(hObject, eventdata, handles)

% hObject    handle to slider5 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.

if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor',[.9 .9 .9]);

end

% --- Executes on button press in pushbutton1.

function pushbutton1_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

la=str2num(get(handles.edit1,'String')).*10.^(-9);

num=str2num(get(handles.edit2,'String'));

d=num.*10.^(-3);

D=str2num(get(handles.edit3,'String'));

A1=str2num(get(handles.edit4,'String'));

A2=str2num(get(handles.edit5,'String'));

%A1=1;

%A2=1; %光源振幅

xm=0.005;%接收屏范围

ym=xm;

n=1001;

xs=linspace(-xm,xm,n);

ys=linspace(-ym,ym,n);

r1=sqrt((xs+d/2).^2+ys.^2+D.^2);

r2=sqrt((xs-d/2).^2+ys.^2+D.^2);

E1=A1./r1.*exp(1i*r1*2*pi/la);

E2=A2./r1.*exp(1i*r2*2*pi/la);

E=E1+E2;

I=abs(E).^2;

NCL=255;%确定所用灰度等级为255级

Br=(I/4)*NCL;

axes(handles.axes2)

image(xs,ys,Br);

colormap(gray(NCL));

xlabel('双缝干涉条纹')

axes(handles.axes3)

plot(xs,I);

xlabel('干涉强度曲线')

% --- Executes on button press in pushbutton3.

function pushbutton3_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton3 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

delete(gcf);

untitled;

3 仿真结果

4 参考文献

[1]李喜贵, 张阳. MATLAB编程实现杨氏双缝干涉实验的计算机动态模拟[C]// 第六届全国高等学校物理实验教学研讨会. 0.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

Matlab实现杨氏双缝干涉和(单缝+多缝+圆孔+矩孔)衍射相关推荐

  1. 用matlab电磁波双缝干涉实验报告,基于MATLAB的杨氏双缝干涉实验的研究

    1杨氏双缝干涉 如图1所示,设单缝光阑S 到狭缝S 1和S 2距离相等,狭缝S 1和S 2的宽度均为b ,双缝之间遮光部分的宽为a ,双缝间的距离为d (d =a +b ),光屏离双缝的距离为D . ...

  2. 杨氏双缝干涉 matlab仿真,基于MATLAB的杨氏双缝干涉实验仿真.pdf

    基于MATLAB的杨氏双缝干涉实验仿真.pdf ( ) 第 27卷 湖北师范学院学报 自然科学版 Vol27 第 1期 Jou rnal of Hubei Norm al U n iversity ( ...

  3. 杨氏双缝干涉 matlab仿真,基于MATLAB的杨氏双缝干涉实验仿真

    第 27卷 湖北师范学院学报 (自然科学版 ) Vol27 第 1期 Journal of HubeiNormalUniversity (Natural Science) No11, 2007 基于 ...

  4. 【光学】基于matlab GUI杨氏双缝干涉【含Matlab源码 001期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[光学]基于matlab GUI杨氏双缝干涉[含Matlab源码 001期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: 付费 ...

  5. MATLAB:杨氏双缝干涉实验(Young‘s Interference)

    目录 1.概念 2.MATLAB代码实现 1.概念 提出时间:1801年 提出者:托马斯·杨​(Thomas Young) 双缝干涉实验起源于光学研究,以它的发现者​托马斯·杨​(Thomas You ...

  6. 用matlab电磁波双缝干涉实验报告,matlab演示杨氏双缝干涉实验

    本文采用gui演示杨氏双缝干涉实验,可以调整参数,实验原理详参光学教程. %读入实验参数 lambda=str2num(get(handles.edit1,'string'))*1e-9;  %读入波 ...

  7. matlab模拟杨氏双缝干涉实验

    光学第二次作业 习题 杨氏双缝干涉:双缝间距1mm\rm 1mm1mm,接收屏到双缝的间距为1.5m\rm 1.5m1.5m,光源波长为0.632um\rm 0.632um0.632um 计算出条纹间 ...

  8. 基于matlab的杨氏双缝干涉模拟仿真+GUI界面

    目录 1.算法仿真效果 2.MATLAB源码 3.算法概述 4.部分参考文献 1.算法仿真效果 matlab2022a仿真结果如下: 2.MATLAB源码 %********************* ...

  9. matlab:杨氏双缝干涉

    基本原理: 杨氏干涉实验是两点光源干涉实验的典型代表.杨氏干涉实验以极简单的装置和巧妙构思实现了普通光源干涉.无论从经典光学还是从现代光学的角度来看,杨氏实验都具有十分重要的意义. 杨氏双缝实验的装置 ...

  10. 【光学】Matlab实现杨氏双缝干涉仿真

最新文章

  1. 几个流行移动前端框架的比较评分
  2. ROS创建工作空间与节点
  3. textContent与innerText的不同(转)
  4. 2016年软考网络工程师考试命题范围变化之网络设备配置与复习技巧
  5. 基于Java的RDMA高性能通信库(六):SDP - Java Socket Direct Protocol
  6. 分布式架构的水平和垂直扩容
  7. WINDOWS 2008 AD权限管理服务(ADRMS)完全攻略
  8. c语言ue,小话C语言中的cotinue和break
  9. 深入解析GBDT二分类算法(附代码实现)
  10. CoreAnimation汇总
  11. oracle 12c grid db 安装的的checklist
  12. MySQL 5.5 到MySQL 5.6半同步复制(SSL)
  13. 安卓nfs网络文件服务器,Linux网络文件服务器 NFS
  14. linux下反汇编命令,Linux命令学习手册-objdump命令
  15. ENVI学习总结(六)——图像自动配准
  16. 计算机网络技术自谋职业,过去认知或许都是错的 主编告诉你游戏PC该怎么选
  17. mplayer-ww-37356 compile with mingw gcc 4.5.1 修复无法播放wmv
  18. 南极沉船_世界上一些神秘的沉船,都成了仿佛被世界遗弃的盛景
  19. 2022年8月深圳CPDA数据分析师认证报名
  20. 在c语言中的变量分为三种类型,在C语言中的实型变量分为两种类型,它们是_______和__________ 答案:float double...

热门文章

  1. 锚定本地化:电子签杀入下半场
  2. 中北大学光电考试复习目录
  3. 强烈推荐这个Java学习文档——不看后悔系列
  4. 硬件时序图软件——TimeGen_v3.3
  5. 前端实现Word在线预览
  6. Windows美化方案,个性不光是壁纸!
  7. win10默认壁纸_Win10瞬间审美爆炸,5分钟一键美化,不输万元Mac!
  8. Docker 下载安装使用(简单教程)
  9. python使用筛选法求素数
  10. 强化学习学习总结(二)——QLearning算法更新和思维决策