ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

【光学】 基于matlab GUI光的双缝干涉【含Matlab源码 455期】

2021-06-28 20:32:28  阅读:164  来源: 互联网

标签:13 light GUI 455 hObject handles 源码 gui


一、简介

基于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

三、运行结果

在这里插入图片描述

四、备注

版本:2014a
完整代码或代写加QQ1564658423

标签:13,light,GUI,455,hObject,handles,源码,gui
来源: https://www.cnblogs.com/homeofmatlab/p/14946131.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有