function varargout = main(varargin)
% MAIN MATLAB code for main.fig
% MAIN, by itself, creates a new MAIN or raises the existing
% singleton*.
%
% H = MAIN returns the handle to a new MAIN or the handle to
% the existing singleton*.
%
% MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MAIN.M with the given input arguments.
%
% MAIN('Property','Value',...) creates a new MAIN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before main_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to main_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 main
% Last Modified by GUIDE v2.5 05-Jun-2016 10:59:22
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @main_OpeningFcn, ...
'gui_OutputFcn', @main_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 main is made visible.
function main_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 main (see VARARGIN)
% Choose default command line output for main
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes main wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = main_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 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)
if get(handles.radiobutton1,'value')
option=1;
elseif get(handles.radiobutton2,'value')
option=2;
elseif get(handles.radiobutton3,'value')
option=3;
end
pop=get(handles.popupmenu1,'value');
x=-0.01:0.00005:0.01;
y=-0.01:0.00005:0.01; %设置屏幕上观测范围
[X,Y]=meshgrid(x,y); %制作xy平面上的点
% load red;
%准备部分
%%
switch pop
case 1
D=str2double(get(handles.edit1,'string'));
lam=str2double(get(handles.edit2,'string'))/1000000000;
d=str2double(get(handles.edit3,'string'))/1000;
I0=str2double(get(handles.edit4,'string'));
n=str2double(get(handles.edit6,'string'));
%D=1;lam=600e-9;d=2e-4;I0=1;n=1; %参数(屏距,波长,缝距,光强,传播介质)
r1=sqrt((X+d/2).^2+Y.^2+D^2); %点与光源1的光程
r2=sqrt((X-d/2).^2+Y.^2+D^2); %点与光源2的光程
Delta=(2*n.*X*d)./(r1+r2); %光程差
delta=(2*pi.*Delta)./(lam*D); %相位差
I=4*I0*(cos(delta./2)).^2; %光强分布
%计算部分
%%
switch option
case 1
mesh(X,Y,I);
colormap(hot);
axes(handles.axes1);
view(0,0);
xlabel(['光屏x轴(m) 缝距=',num2str(d),'(m)']); % x轴注解
zlabel('光照强度'); % y轴注解
title('强度曲线','FontName','黑体','FontSize',17); % 图形标题
%%
case 2
mesh(X,Y,I);
colormap(copper);
axes(handles.axes1);
view(0,90);
xlabel('光屏x轴(m)');
ylabel('光屏y轴(m)');
title('二维干涉条纹','FontName','黑体','FontSize',17);
%%
case 3
mesh(X,Y,I);
colormap(copper);
axes(handles.axes1);
view(-13,80);
xlabel('光屏x轴(m)');
ylabel('光屏y轴(m)');
zlabel('光照强度','FontSize',8);
title('三维强度分布','FontName','黑体','FontSize',17);
end
case 2
x=0:0.05:8*pi;
y=-0.01:0.00005:0.01; %设置屏幕上观测范围
[X,Y]=meshgrid(x,y); %制作xy平面上的点
%%
R=str2double(get(handles.edit5,'string'))/100;
set(handles.text7,'string','折射率');
%R=0.64;
%%
F=4*R/(1-R)^2;
Ir=F*(sin(X./2)).^2;
Ii=1+F*(sin(X./2)).^2;
A=Ir./Ii;
switch option
case 1
mesh(X,Y,A);
axes(handles.axes1);
view(0,0);
colormap(hot);
xlabel('delta','FontName','Times New Roman'); % x轴注解0
zlabel('Ir/Ii','FontName','Times New Roman'); % y轴注解
title('强度曲线','FontName','黑体','FontSize',17); % 图形标题
case 2
mesh(X,Y,A);
axes(handles.axes1);
view(0,90);
colormap(pink);
xlabel('光屏x轴');
ylabel('光屏y轴');
title('二维干涉条纹','FontName','黑体','FontSize',17);
case 3
mesh(X,Y,A);
axes(handles.axes1);
view(-25,35);
colormap(pink);
xlabel('光屏x轴(delta)');
ylabel('光屏y轴');
zlabel('Ir/Ii','FontSize',12);
title('三维强度分布','FontName','黑体','FontSize',17);
end
case 3
x=0:0.05:8*pi;
y=-0.01:0.00005:0.01; %设置屏幕上观测范围
[X,Y]=meshgrid(x,y); %制作xy平面上的点
%%
R=str2double(get(handles.edit5,'string'))/100;
set(handles.text7,'string','折射率');
%R=0.64;
%%
F=4*R/(1-R)^2;
Ii=1+F*(sin(X./2)).^2;
A=1./Ii;
switch option
case 1
mesh(X,Y,A);
axes(handles.axes1);
view(0,0);
colormap(hot);
xlabel('delta','FontName','Times New Roman'); % x轴注解0
zlabel('It/Ii','FontName','Times New Roman'); % y轴注解
title('强度曲线','FontName','黑体','FontSize',17); % 图形标题
case 2
mesh(X,Y,A);
axes(handles.axes1);
view(0,90);
colormap(pink);
xlabel('光屏x轴(m)');
ylabel('光屏y轴(m)');
title('二维干涉条纹','FontName','黑体','FontSize',17);
case 3
mesh(X,Y,A);
axes(handles.axes1);
view(-25,35);
colormap(pink);
xlabel('光屏x轴(delta)');
ylabel('光屏y轴(m)');
zlabel('It/Ii','FontSize',12);
title('三维强度分布','FontName','黑体','FontSize',17);
end
case 4
z=str2double(get(handles.edit1,'string'))/10;
lam=str2double(get(handles.edit2,'string'))/1000000000;
a=str2double(get(handles.edit3,'string')