基于matlab GUI光的双缝干涉
function varargout = gui_light_13_9(varargin)
% GUI_LIGHT_13_9 M-file for gui_light_13_9.fig
% GUI_LIGHT_13_9, by itself, creates a new GUI_LIGHT_13_9 or raises the existing
% singleton*.
%
% H = GUI_LIGHT_13_9 returns the handle to a new GUI_LIGHT_13_9 or the handle to
% the existing singleton*.
%
% GUI_LIGHT_13_9('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_LIGHT_13_9.M with the given input arguments.
%
% GUI_LIGHT_13_9('Property','Value',...) creates a new GUI_LIGHT_13_9 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gui_light_13_9_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to gui_light_13_9_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 gui_light_13_9
% Last Modified by GUIDE v2.5 08-Sep-2007 17:51:39
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @gui_light_13_9_OpeningFcn, ...
'gui_OutputFcn', @gui_light_13_9_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 gui_light_13_9 is made visible.
function gui_light_13_9_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 gui_light_13_9 (see VARARGIN)
% Choose default command line output for gui_light_13_9
set(handles.lambda_edit,'String',0.0000006);
set(handles.d_edit,'String',0.0015);
set(handles.z_edit,'String',2);
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes gui_light_13_9 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = gui_light_13_9_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;
% --- Executes on button press in light_pushbutton.
function light_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to light_pushbutton (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.lambda_edit,'String'));
d=str2num(get(handles.d_edit,'String'));
z=str2num(get(handles.z_edit,'String'));
yMax=5*Lambda*z/d;xs=yMax;
Ny=101;ys=linspace(-yMax,yMax,Ny);
for i=1:Ny
L1=sqrt((ys(i)-d/2).^2+z.^2);
L2=sqrt((ys(i)+d/2).^2+z.^2);
Phi=2*pi*(L2-L1)/Lambda;
B(i,:)=4*cos(Phi/2).^2;
end
NCL=255;%确定所用灰度等级为255级
Br=(B/4.0)*NCL;%定标,使最大光强(4.0)定为最大灰度级(白色)
axes(handles.axes1)
image(xs,ys,Br);
colormap(gray(NCL));
xlabel('双缝干涉条纹')
axes(handles.axes2)
plot(B(:),ys);
xlabel('双缝干涉光强分布')
% --- Executes on button press in close_pushbutton.
function close_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to close_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close
function lambda_edit_Callback(hObject, eventdata, handles)
% hObject handle to lambda_edit (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 lambda_edit as text
% str2double(get(hObject,'String')) returns contents of lambda_edit as a double
% --- Executes during object creation, after setting all properties.
function lambda_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to lambda_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
完整代码或者代写添加QQ912100926
往期回顾>>>>>>
【物理应用】杨氏双缝干涉实验【Matlab 310期】
【物理应用】井筒多相流【Matlab 311期】
【物理应用】二维对流扩散温度场【Matlab 312期】
【物理应用】内弹道【Matlab 313期】
【物理应用】两个光纤光栅的新光子微波发生器的仿真分析【Matlab 314期】
【物理应用】计算油气井井底压力【Matlab 315期】
【物理应用】光流场【Matlab 316期】
【物理应用】带电粒子在放射状电场和均匀磁场下的混沌运动模拟【Matlab 317期】
【物理应用】异构交通流【Matlab 318期】
【物理应用】模拟斜抛运动含GUI界面【Matlab 319期】
【物理应用】计算晶体结构的x射线衍射图谱【Matlab 320期】
【物理应用】衍射光栅教学版【Matlab 321期】
【物理应用】电荷电场线和电势【Matlab 322期】
【物理应用】速度场找到漩涡【Matlab 323期】
【物理应用】Simulink三相异步电机仿真【Matlab 324期】
【物理应用】悬吊式起重机动力学仿真【Matlab 325期】
【物理应用】车道检测仿真【Matlab 326期】
【物理应用】基于GUI界面的电偶极子【Matlab 327期】
【物理应用】车载自组织网络中路边性能及防碰撞算法研究【Matlab 328期】
【物理应用】Q学习的无线体域网路由方法【Matlab 329期】
【电路仿真】基于simulink三相相控变流器的设计【Matlab 330期】
【物理应用】导线网坐标计算【Matlab 331期】
【物理应用】功率谱估计【Matlab 332期】
【物理应用】基于动态矩阵控制方法的热水器出口温度控制【Matlab 333期】
【电路仿真】基于simulink三相半波可控整流电路【Matlab 334期】
【电路仿真】基于simulink三相桥式全控整流电路【Matlab 335期】
【物理应用】基于GUI家庭室内温湿度控制【Matlab 336期】
【电路仿真】基于simulink模拟锁相环设计【Matlab 337期】
【电路仿真】基于simulink全数字锁相环设计【Matlab 338期】
【物理应用】基于直角坐标的电力系统潮流计算【Matlab 339期】
【光学】单缝衍射【Matlab 340期】
【物理应用】基于RBF神经网络算法控制卫星轨道和姿态【Matlab 341期】
【物理应用】基于matlab红绿灯车辆数量识别【Matlab 342期】
【电路仿真】基于simulink四旋翼的PID控制【Matlab 343期】