【物理应用】基于Matlab模拟杨氏双孔干涉实验
1 内容介绍
根据光的双缝干涉实验理论,利用MATLAB编写程序对双缝干涉实验进行模拟,绘制出双缝干涉的图样和光强分布曲线,并且同步计算出相应的条纹间距和对比度,直观地展现了单色光的双缝干涉这一物理现象,实验结果与实际计算结果一致,为双缝干涉的理论与实验提供了有效的支持.
2 部分代码
function varargout = ganshe(varargin)
% GANSHE M-file for ganshe.fig
% GANSHE, by itself, creates a new GANSHE or raises the existing
% singleton*.
%
% H = GANSHE returns the handle to a new GANSHE or the handle to
% the existing singleton*.
%
% GANSHE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GANSHE.M with the given input arguments.
%
% GANSHE('Property','Value',...) creates a new GANSHE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before ganshe_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to ganshe_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 ganshe
% Last Modified by GUIDE v2.5 21-Jun-2014 11:31:04
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @ganshe_OpeningFcn, ...
'gui_OutputFcn', @ganshe_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 ganshe is made visible.
function ganshe_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 ganshe (see VARARGIN)
% Choose default command line output for ganshe
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes ganshe wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = ganshe_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)
% 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
function edit2_Callback(hObject, eventdata, handles)
% 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
function edit3_Callback(hObject, eventdata, handles)
% 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
function edit4_Callback(hObject, eventdata, handles)
% 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');
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (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
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (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 edit7 as text
% str2double(get(hObject,'String')) returns contents of edit7 as a double
% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (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
function edit8_Callback(hObject, eventdata, handles)
% hObject handle to edit8 (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 edit8 as text
% str2double(get(hObject,'String')) returns contents of edit8 as a double
% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (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
function edit9_Callback(hObject, eventdata, handles)
% hObject handle to edit9 (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 edit9 as text
% str2double(get(hObject,'String')) returns contents of edit9 as a double
% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit9 (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 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)
%读入实验参数
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('杨氏双孔干涉条纹')
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- 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)
3 运行结果
4 参考文献
[1]盛虹. 基于MATLAB的杨氏双缝干涉实验模拟[J]. 河南科学, 2010, 28(6):3.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机、雷达通信、无线传感器等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
【物理应用】基于Matlab模拟杨氏双孔干涉实验相关推荐
- 【光学】基于matlab模拟双孔干涉附matlab代码
1 内容介绍 通过Matlab软件编程,实现光学双缝干涉的计算机仿真.仿真结果对学生理解光学原理的基本概念很有帮助,提高了教学效果. 2 部分代码 %REDME!!!该仿真模拟了双孔干事实验中光屏逐 ...
- 【光学】基于matlab GUI双孔干涉【含Matlab源码 2119期】
⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[光学]基于matlab GUI双孔干涉[含Matlab源码 2119期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: 付费 ...
- matlab模拟方孔衍射,基于MATLAB衍射的矩形孔实验模拟
翌 毫研夯一一_ 乜业岍九 基于 MATLAB衍射昀矩形孔实验旗拟 张 亚 陈冬冬 成海英 /盐城工学院 [摘 要]根据物理光学中光的矩形孔衍射理论,利用 MATLAB工具编写程序进行实验模拟,绘 出 ...
- 【物理应用】基于matlab模拟井筒多相流【含Matlab源码 2152期】
⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[物理应用]基于matlab模拟井筒多相流[含Matlab源码 2152期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: 付 ...
- 用matlab电磁波双缝干涉实验报告,基于MATLAB的杨氏双缝干涉实验的研究
1杨氏双缝干涉 如图1所示,设单缝光阑S 到狭缝S 1和S 2距离相等,狭缝S 1和S 2的宽度均为b ,双缝之间遮光部分的宽为a ,双缝间的距离为d (d =a +b ),光屏离双缝的距离为D . ...
- 基于Matlab模拟、检测和跟踪飞机着陆进场中异常的仿真(附源码)
目录 一.介绍 二.生成和标记轨迹 三.定义方案 四.运行方案并检测异常轨道 五.将跟踪异常报告与事实进行比较 六.总结 七.程序 该示例显示了如何自动检测最终接近机场跑道的飞机的偏差和异常.在此示例 ...
- 【光学】基于matlab模拟拉盖尔高斯【含Matlab源码 2167期】
⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[光学]基于matlab模拟拉盖尔高斯[含Matlab源码 2167期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: 付费专 ...
- 杨氏双缝干涉 matlab仿真,基于MATLAB的杨氏双缝干涉实验仿真
第 27卷 湖北师范学院学报 (自然科学版 ) Vol27 第 1期 Journal of HubeiNormalUniversity (Natural Science) No11, 2007 基于 ...
- 【光学】基于matlab GUI杨氏双缝干涉【含Matlab源码 001期】
一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[光学]基于matlab GUI杨氏双缝干涉[含Matlab源码 001期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: 付费 ...
最新文章
- Scala 学习笔记(1)
- 关于 URL 的一些不可不知的知识
- 网络:TIME-WAIT
- Reveal使用步骤和 破解Revealapp的试用时间限制
- windows2003+iis6.0+php(fastcgi)5.3+wincache+memcached
- 新天龙八部服务器维护了吗,《新天龙八部》3月11日全服更新维护公告
- creator 静态属性_CocosCreator cc.class声明类
- 卷积神经网络_mnist
- Android 热修复的相关总结(主要是阿里百川的)
- 【行为识别】基于matlab差影法三维人体姿态行为识别【含Matlab源码 277期】
- python中调用shell命令
- ArcGIS三维制作步骤
- 华为手机从浏览器安装第三方软件签名不一致如何强制安装
- mysql-世界-全球数据
- 要用计算机处理频谱,妙用Adobe Audition 系列教程(二):频谱分析仪 | 小众声学...
- 计算机 蚂蚁搬家 教案,小班蚂蚁搬家的教案
- 共享的快捷方式会经常突然不见_突然爆红的共享自习室,会是一个新风口吗?...
- H5网页元素和全局属性
- python已打开页面获取信息_python+selenium实现自动登录网页获取信息(一)
- 哥德巴赫猜想计算机验证进展,哥德巴赫猜想的最新进展,不知道下文证明的是否正确,求验证...
热门文章
- ie下ajax请求不到数据库,解决IE下Ajax请求无效
- C/C++简单实现文件分块
- 在外部DDR3内存中运行的MicroBlaze程序的固化方法
- ESP8266-Arduino编程实例-BMA250加速度传感器驱动
- et文件怎么转成excel_一键将PDF转成Word、PPT和Excel!这么简单的方法很多人还不知道...
- 基于Python实现的网络嗅探器【100010784】
- 2010年世界杯分组
- 除了男足,中国元素霸占了世界杯
- nmap扫描、信息收集(网安全实训第一天)
- java判断浏览器杂项_java简单代码判断浏览器代码